geonature.core.gn_synthese.utils.query_select_sqla
Utility function to manage permissions and all filter of Synthese Use these functions rather than query.py Filter the query of synthese using SQLA expression language and “select” object https://docs.sqlalchemy.org/en/latest/core/tutorial.html#selecting much more efficient
Module Contents
Classes
class for building synthese query and manage join |
Functions
|
- class geonature.core.gn_synthese.utils.query_select_sqla.SyntheseQuery(model, query, filters, id_synthese_column='id_synthese', id_dataset_column='id_dataset', observers_column='observers', id_digitiser_column='id_digitiser', with_generic_table=False, query_joins=None, geom_column=None)[source]
class for building synthese query and manage join
- Attributes:
query: SQLA select object filters: dict of query string filters model: a SQLA model _already_joined_table: (private) a list of already joined table. Auto build with “add_join” method query_joins = SQLA Join object
- build_permissions_filter(user, permissions)[source]
Return a where clause for the given permissions set
- filter_query_with_permissions(user, permissions)[source]
Filter the query with the permissions of a user
- filter_query_with_cruved(user, scope)[source]
Filter the query with the cruved authorization of a user
- filter_taxonomy()[source]
Filters the query with taxonomic attributes Parameters:
q (SQLAchemyQuery): an SQLAchemy query
filters (dict): a dict of filter
- Returns:
-Tuple: the SQLAlchemy query and the filter dictionnary
- filter_query_all_filters(user, permissions)[source]
High level function to manage query with all filters.
Apply CRUVED, taxonomy and other filters.
Parameters
- user: str
User filtered by CRUVED.
Returns
- sqlalchemy.orm.query.Query.filter
Combined filter to apply.
- build_bdc_status_pr_nb_lateral_join(protection_status_value, red_list_filters)[source]
Create subquery for bdc_status filters
- Objectiffiltrer les données ayant :
les statuts du type demandé par l’utilisateur
les status s’appliquent bien sur la zone géographique de la donnée (c-a-d le département)
- Idée de façon à limiter le nombre de sous reqêtes,
la liste des status selectionnés par l’utilisateur s’appliquant à l’observation est aggrégée de façon à tester le nombre puis jointé sur le département de la donnée