Skip to content

Commit

Permalink
Merge branch 'master' into background_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
hypsug0 committed Mar 25, 2024
2 parents b54059d + 094fe99 commit f961446
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 260 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: "🎳 Tester"
on:
push:
branches:
- main
- master
paths:
- "**.py"
- .github/workflows/tester.yml
- requirements/testing.txt

pull_request:
branches:
- main
- master
paths:
- "**.py"
- .github/workflows/tester.yml
Expand Down Expand Up @@ -46,6 +46,9 @@ jobs:

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: lpoaura/PluginQGis-LPOData

test-qgis:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -73,7 +76,7 @@ jobs:
run: python3 --version

- name: Setup plugin
run: qgis_setup.sh qtribu
run: qgis_setup.sh plugin_qgis_lpo

- name: Install Python requirements
run: |
Expand All @@ -85,3 +88,7 @@ jobs:

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: lpoaura/PluginQGis-LPOData

14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this

<!-- ## Unreleased [{version_tag}](https://github.com/opengisch/qgis-plugin-ci/releases/tag/{version_tag}) - YYYY-MM-DD -->

## Unreleased
## Unreleased - 2024-03-25

* Migrate wiki docs to github pages using sphinx
* Update github workflows
* Update plugin name
* Move refresh data from plugin menu to plugin settings window

## 3.2.2 - 2024-03-14

* Load plugin menu on plugin startup
* Update queries
* New pre-commit SQL formatter
* Update tester github workflow

## 3.2.1 - 2024-03-14

Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ caption: Usage
maxdepth: 1
---
Installation <usage/installation>
Filtrage avancé (SQL) <usage/advanced_filter>
```

```{toctree}
Expand Down
39 changes: 39 additions & 0 deletions docs/usage/advanced_filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Filtres personnalisés en langage SQL

📢 Pour chaque traitement, il vous est possible de **filtrer de manière personnalisée** les données traitées, en ajoutant des **clauses "where" en langage SQL** dans les `Paramètres avancés`. Vous trouverez ci-dessous les exemples possibles.

## Filtres classiques

:::{Warning}
A partir de la version `3.0.0`, le `and` en début de requête n'est plus à mentionner.
:::


|Filtrer sur...|Un seul critère|Plusieurs critères|
|-|-|-|
|id espèce VisioNature|`and source_id_sp = 386`|`and source_id_sp in (386, 394, 370)`|
|cd_nom|`and obs.cd_nom = 4001`|`and obs.cd_nom in (4001, 4035, 3764)`|
|Nom vernaculaire|`and t.nom_vern ilike 'Rougegorge familier'` ou `and t.nom_vern ilike '%rougegorge%'`|`and t.nom_vern in ('Rougegorge familier', 'Rougequeue noir', 'Mésange charbonnière')`|
|Nom scientifique|`and t.lb_nom ilike 'erithacus rubecula'`|`and t.lb_nom in ('Erithacus rubecula', 'Phoenicurus ochruros', 'Parus major')`|
|Observateur|`and observateur = 'NOM Prénom'`|`and observateur in ('NOM Prénom', 'NOM Prénom', 'NOM Prénom')`|
|Code de nidification|`and oiso_code_nidif = 1`|`and oiso_code_nidif in (1, 2, 3)`|
|Statut de reproduction (valable pour tous les groupes taxo)|`and statut_repro = 'Certain'`|`and statut_repro in ('Certain', 'Probable', 'Possible')`|
|Cause de mortalité|`and mortalite_cause = 'ROAD_VEHICLE'`|`and mortalite_cause in ('ROAD_VEHICLE', 'HUNTING')`|
|Code étude|`and code_etude = 'EPOC'`|`and code_etude in ('EPOC', 'EPOC-ODF')`|

La fonction `ilike` permet de s'affranchir des majuscules et minuscules. Le % remplace un ou plusieurs caractères (et ne fonctionne qu'avec ilike).


## Autres filtres plus complexes

- Filtrer sur l'**altitude** :
- Entre deux altitudes : `and altitude >= 1000 and altitude < 2000`
- Sous un seuil d'altitude et au-dessus d'un autre seuil : `and (altitude <= 1000 or altitude > 2000)`
- Filtrer sur la **mortalité** :
- Ne garder que les données de mortalité : `and mortalite = true`
- Exclure les données de mortalité : `and mortalite = false`
- Rechercher un mot ou une expression dans les **commentaires** : `and commentaires like '%mangeoire%'`
- Filtrer sur le **comportement** :
- Rechercher un comportement particulier : `and comportement @> '{"Se nourrit"}'`
- Rechercher plusieurs comportements <u>simultanés</u> : `and comportement @> '{"Se nourrit", "Se déplace"}'`
- Rechercher plusieurs comportements pas forcément simultanés : `and (comportement @> '{"Se nourrit"}' or comportement @> '{"Se déplace"}')`
25 changes: 23 additions & 2 deletions plugin_qgis_lpo/gui/dlg_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
from pathlib import Path
from urllib.parse import quote

import processing

# PyQGIS
from qgis.core import Qgis, QgsApplication
from qgis.core import (
Qgis,
QgsApplication,
QgsProcessingException,
QgsProviderConnectionException,
QgsProviderRegistry,
)
from qgis.gui import QgsOptionsPageWidget, QgsOptionsWidgetFactory
from qgis.PyQt import uic
from qgis.PyQt.Qt import QUrl
Expand All @@ -25,6 +33,7 @@
__uri_tracker__,
__version__,
)
from plugin_qgis_lpo.processing.refresh_data import RefreshData
from plugin_qgis_lpo.toolbelt import PlgLogger, PlgOptionsManager
from plugin_qgis_lpo.toolbelt.preferences import PlgSettingsStructure

Expand Down Expand Up @@ -76,15 +85,27 @@ def __init__(self, parent):
)

self.btn_report.pressed.connect(
partial(QDesktopServices.openUrl, QUrl(f"{__uri_tracker__}new/choose"))
partial(QDesktopServices.openUrl, QUrl(f"{__uri_tracker__}/new/choose"))
)

self.btn_reset.setIcon(QIcon(QgsApplication.iconPath("mActionUndo.svg")))
self.btn_reset.pressed.connect(self.reset_settings)

self.btn_refresh_data.setIcon(QIcon(str(__icon_dir_path__ / "refresh.png")))
self.btn_refresh_data.pressed.connect(
lambda: self.openRefreshProcessing(parent)
)
self.log(f"TYPE PARENT {type(parent)}", log_level=0, push=True)
# load previously saved settings
self.load_settings()

def openRefreshProcessing(self, parent):
"""Open refresh data processing algorithm and close settings window"""
processing.createAlgorithmDialog(
f"plugin_qgis_lpo:{RefreshData().name()}"
).show()
parent.close()

def apply(self):
"""Called to permanently apply the settings shown in the options page (e.g. \
save them to QgsSettings objects). This is usually called when the options \
Expand Down
Loading

0 comments on commit f961446

Please sign in to comment.