Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| efac172ac8 | |||
| 337f68f2fc | |||
| 2d43654c81 | |||
| edfe6dd65e | |||
| 021361e2c1 | |||
| 04ec9438f1 | |||
| e6960dc16d | |||
| 2fb71e466c | |||
| b47463b638 | |||
| 84cf48182d | |||
| 0f11a575ff | |||
| c9459771ac | |||
| 99eef0eaa3 | |||
| 4719ef5754 | |||
| 032ca5554e | |||
| 90d66bcbb6 | |||
| 43104f611e | |||
| 24ef21761f | |||
| e0fa8464d2 | |||
| 0691329b04 | |||
| 359ba248ac | |||
| 19d7735306 | |||
| 43fd2df2c0 | |||
| 9ae6f29391 | |||
| 80a7e51ec4 | |||
| e216b42379 | |||
| 7f42ca67a2 | |||
| ec15852406 | |||
| 8c98a60c75 | |||
| 565a0cfd08 | |||
| 53919bff3e | |||
| 193cf5302c | |||
| fd2f87e382 | |||
| 59e363a1fc | |||
| fdeedde983 | |||
| 925d050c96 | |||
| 5d4ee692f3 | |||
| a51d2a83b4 | |||
| 6b133c21ab | |||
| 503ec33f43 | |||
| 6b6d2ca790 | |||
| fa84271759 | |||
| d8f5739168 | |||
| dd07351bdd | |||
| 4fb376d43d | |||
| 2335ae3d59 | |||
| 9e9770b1a0 | |||
| ce4570afad | |||
| 4c72c0e269 | |||
| 9a035ae431 | |||
| f511c4fcef | |||
| d58183beb5 | |||
| 18f8388df5 | |||
| ef39be3346 | |||
| 783fb88d0c | |||
| c19076ee85 | |||
| c44ef311c3 | |||
| 63622d83f5 | |||
| 5bfce2a1d9 | |||
| a3f8bd0981 | |||
| bb6c0dec26 | |||
| 459ca6a846 | |||
| 8637915eb2 | |||
| e187cf33aa | |||
| 2f3ce6a467 | |||
| 1310caef4d | |||
| efd9bd4238 | |||
| 39844071ad | |||
| 5c64177c6a | |||
| 1e85dbe562 | |||
| 6835f328b6 | |||
| a3eb48bacb | |||
| 1848c881ac | |||
| bbb04a4487 | |||
| e9faf80609 | |||
| f6a38a29bd | |||
| c6e096e42a | |||
| 4c6f63f723 | |||
| f3c8fd4481 | |||
| 5ca52fadd7 | |||
| ee91e7a91f | |||
| 392f862baa | |||
| 199476ec30 | |||
| c98a36f759 | |||
| 65e0f4c5f0 | |||
| bc7652f336 | |||
| 188383a882 | |||
| 7f3a0bcb21 | |||
| 3270abb7f6 | |||
| 2eb984a95f | |||
| 776126a481 | |||
| 59abf35a12 | |||
| a40eb64245 | |||
| acae1517cb | |||
| 9a9decde6e | |||
| a1ae962c73 | |||
| 0404aa0973 | |||
| effe01dedf | |||
| aaa70039d2 | |||
| 7dc5f09545 | |||
| 91e7f373ec | |||
| c7768ea8f1 | |||
| 816d0de324 | |||
| c2fab377d5 | |||
| d7cdf38cda | |||
| 85f0084b7b | |||
| 712dc5a7f8 | |||
| 84b94fd882 | |||
| 90e9bc3c8c |
@@ -3,12 +3,23 @@ PORT=8050
|
|||||||
DEVELOPMENT=True
|
DEVELOPMENT=True
|
||||||
SOURCE_STATS_CSV_PATH="https://www.data.gouv.fr/api/1/datasets/r/8ded94de-3b80-4840-a5bb-7faad1c9c234"
|
SOURCE_STATS_CSV_PATH="https://www.data.gouv.fr/api/1/datasets/r/8ded94de-3b80-4840-a5bb-7faad1c9c234"
|
||||||
|
|
||||||
|
# Annonce dans l'en-tête du site
|
||||||
|
ANNOUNCEMENTS=
|
||||||
|
|
||||||
# Chemin vers le schéma de données
|
# Chemin vers le schéma de données
|
||||||
DATA_SCHEMA_PATH=https://www.data.gouv.fr/api/1/datasets/r/9a4144c0-ee44-4dec-bee5-bbef38191d9a
|
DATA_SCHEMA_PATH=https://www.data.gouv.fr/api/1/datasets/r/9a4144c0-ee44-4dec-bee5-bbef38191d9a
|
||||||
|
|
||||||
|
# Colonnes masquées par défaut
|
||||||
|
DISPLAYED_COLUMNS="uid, acheteur_id, acheteur_nom, montant, objet, titulaire_nom, titulaire_id, dateNotification, dureeMois, acheteur_departement_code, sourceDataset"
|
||||||
|
|
||||||
# Formulaire de contact
|
# Formulaire de contact
|
||||||
SENDER_SERVER_DOMAIN="mail.example.com" # serveur SMTP
|
SENDER_SERVER_DOMAIN="mail.example.com" # serveur SMTP
|
||||||
LOGIN_PASSWORD="" # mot de passe du serveur
|
LOGIN_PASSWORD="" # mot de passe du serveur
|
||||||
LOGIN_EMAIL="connect@example.fr" # adresse utilisée pour se connecter au serveur SMTP
|
LOGIN_EMAIL="connect@example.fr" # adresse utilisée pour se connecter au serveur SMTP
|
||||||
FROM_EMAIL="from@example.com" # adresse d'envoi des emails (From)
|
FROM_EMAIL="from@example.com" # adresse d'envoi des emails (From)
|
||||||
TO_EMAIL="to@example.com" # adresse de destination des emails (To)
|
TO_EMAIL="to@example.com" # adresse de destination des emails (To)
|
||||||
|
|
||||||
|
# Matomo
|
||||||
|
MATOMO_ID_SITE=
|
||||||
|
MATOMO_BASE_URL=
|
||||||
|
MATOMO_TOKEN=
|
||||||
|
|||||||
+137
@@ -0,0 +1,137 @@
|
|||||||
|
##### 2.3.1 (16 janvier 2026)
|
||||||
|
|
||||||
|
- Les champs absents du [schéma](https://www.data.gouv.fr/datasets/donnees-essentielles-de-la-commande-publique-consolidees-format-tabulaire?resource_id=9a4144c0-ee44-4dec-bee5-bbef38191d9a) sont ignorés pour éviter les erreurs
|
||||||
|
|
||||||
|
#### 2.3.0 (24 décembre 2025)
|
||||||
|
|
||||||
|
- Possibilité de filtrer, trier etc. dans les vues acheteur et titulaire
|
||||||
|
- Possibilité de partager les filtres, tris et choix de colonnes via une adresse Web ([exemple](https://decp.info/tableau?filtres=%7Bobjet%7D+icontains+%22d%C3%A9corations+de+no%C3%ABl%22+%26%26+%7BdateNotification%7D+icontains+2025&colonnes=uid%2Cacheteur_id%2Cacheteur_nom%2Ctitulaire_id%2Ctitulaire_nom%2Cobjet%2Cmontant%2CdateNotification%2Cdistance%2Cacheteur_departement_code))
|
||||||
|
- Possibilité de filtrer une colonne avec plusieurs mots
|
||||||
|
|
||||||
|
##### 2.2.3 (4 décembre 2025)
|
||||||
|
|
||||||
|
- mise à jour de l'adresse email de contact (colmo.tech)
|
||||||
|
- message sur l'indisponibilité des données MINEF
|
||||||
|
|
||||||
|
##### 2.2.2 (22 novembre 2025)
|
||||||
|
|
||||||
|
- Correction d'un bug dans le téléchargement Excel
|
||||||
|
|
||||||
|
##### 2.2.1 (15 novembre 2025)
|
||||||
|
|
||||||
|
- Le moteur de recherche ignore les tirets ("franche comté" trouve "Bourgogne-Franche-Comté)
|
||||||
|
- Phrase "tagline" au-dessus du champ de recherche
|
||||||
|
- Les infos de Contact rebasculent dans À propos
|
||||||
|
- Police de caractère "Open Sans" généralisée
|
||||||
|
|
||||||
|
#### 2.2.0 (13 novembre 2025)
|
||||||
|
|
||||||
|
- Moteur de recherche (acheteurs et titulaires) en page d'accueil ([#58](https://github.com/ColinMaudry/decp.info/issues/58))
|
||||||
|
- Top acheteurs / titulaires par montant attribué/remporté (([#55](https://github.com/ColinMaudry/decp.info/issues/55)))
|
||||||
|
- Moins de colonnes affichées par défaut dans Tableau ([#54](https://github.com/ColinMaudry/decp.info/issues/54))
|
||||||
|
|
||||||
|
##### 2.1.7 (11 novembre 2025)
|
||||||
|
|
||||||
|
- Remplacement du formulaire de contact par une adresse email
|
||||||
|
|
||||||
|
##### 2.1.6 (15 octobre 2025)
|
||||||
|
|
||||||
|
- Stabilisation de la vue marché
|
||||||
|
|
||||||
|
##### 2.1.5 (10 octobre 2025)
|
||||||
|
|
||||||
|
- réparation des filtres (notamment < > sur les montants)
|
||||||
|
- remplacement des valeurs "null" dans les tableaux par des cellules vides
|
||||||
|
|
||||||
|
##### 2.1.4 (8 octobre 2025)
|
||||||
|
|
||||||
|
- possibilité de filtrer sur le champ "Source"
|
||||||
|
- création automatique d'une release Github quand je push un tag
|
||||||
|
|
||||||
|
##### 2.1.3 (4 octobre 2025)
|
||||||
|
|
||||||
|
- tentative d'auto-release à chaque création de tag git
|
||||||
|
- adaptation au format TableSchema
|
||||||
|
|
||||||
|
##### 2.1.2 (3 octobre 2025)
|
||||||
|
|
||||||
|
- dataframe global plutôt que lazyframe, pour plus de résilience et charger toutes les données en mémoire
|
||||||
|
|
||||||
|
##### 2.1.1 (1er octobre 2025)
|
||||||
|
|
||||||
|
- ajout d'une section dans À propos sur la qualité et l'exhaustivité des données ([#43](https://github.com/ColinMaudry/decp.info/issues/43))
|
||||||
|
- ajout du nombre de marchés en plus du nombre de lignes dans la vue Tableau
|
||||||
|
|
||||||
|
#### 2.1.0 (30 septembre 2025)
|
||||||
|
|
||||||
|
- Ajout des vues [acheteur](https://decp.info/acheteurs/24350013900189) ([#28](https://github.com/ColinMaudry/decp.info/issues/28)), [titulaire](https://decp.info/titulaires/51903758414786) ([#35](https://github.com/ColinMaudry/decp.info/issues/35)) et [marché](https://decp.info/marches/532239472000482025S00004) ([#40](https://github.com/ColinMaudry/decp.info/issues/40)) 🔎
|
||||||
|
- Ajout des balises HTML meta Open Graph et Twitter ([#39](https://github.com/ColinMaudry/decp.info/issues/39)) pour de beaux aperçus de liens 🖼️
|
||||||
|
- Formulaire de contact ([#48](https://github.com/ColinMaudry/decp.info/issues/48)) 📨
|
||||||
|
- Nom de colonnes plus_agréables ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 💅
|
||||||
|
- Définition des colonnes quand vous passez votre souris sur les en-têtes ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 📖
|
||||||
|
- Affichage du numéro de version près du logo et lien vers ici 🤓
|
||||||
|
- Variables globales uniquement en lecture (😁)
|
||||||
|
|
||||||
|
##### 2.0.1 (23 septembre 2025)
|
||||||
|
|
||||||
|
- Bloquage du bouton de téléchargement si trop de lignes (+ 65000) [#38](https://github.com/ColinMaudry/decp.info/issues/38)
|
||||||
|
- Amélioration du script de déploiement (deploy.sh)
|
||||||
|
- Meilleures instructions d'installation et lancement
|
||||||
|
- Coquilles 🐚
|
||||||
|
|
||||||
|
### 2.0.0 (23 septembre 2025)
|
||||||
|
|
||||||
|
- détails des sources de données
|
||||||
|
- section "À propos" plus développée
|
||||||
|
- correction de bugs dans les filtres de la data table
|
||||||
|
|
||||||
|
#### 2.0.0-alpha
|
||||||
|
|
||||||
|
- Data table fonctionnelle
|
||||||
|
|
||||||
|
### 1.5.0 (28/01/2023
|
||||||
|
|
||||||
|
- fixation des dépendances Python pour plus de stabilité en cas de réinstallation (Pipfile)
|
||||||
|
|
||||||
|
#### 1.4.1 (14/06/2021)
|
||||||
|
|
||||||
|
- ajout des traductions des opérations de filtrage à toutes les vues, pas seulement /db/decp
|
||||||
|
|
||||||
|
### 1.4.0 (14/06/2021)
|
||||||
|
|
||||||
|
- traduction des opérations de filtrage (ex : contains => contient)
|
||||||
|
- élargissement des menus de filtrage
|
||||||
|
- correction du titre de la page des notes de versions
|
||||||
|
|
||||||
|
### 1.3.0 (03/06/2021)
|
||||||
|
|
||||||
|
- utilisation de noms de colonnes plus lisibles dans l'application
|
||||||
|
- suppression des références à la licence et aux données source sur la page d'accueil
|
||||||
|
- correction des liens vers le code source
|
||||||
|
- correction de l'indentation des puces dans les notes de version
|
||||||
|
|
||||||
|
### 1.2.0 (28/05/2021)
|
||||||
|
|
||||||
|
- ajout d'une page "Notes de version"
|
||||||
|
- meilleur lien pour la documentation des champs
|
||||||
|
- déplacement du code de decp.info depuis [ColinMaudry/decp-table-schema-utils](https://github.com/ColinMaudry/decp-table-schema-utils) vers [ColinMaudry/decp.info](https://github.com/ColinMaudry/decp.info)
|
||||||
|
|
||||||
|
### 1.1.0 (25/05/2021)
|
||||||
|
|
||||||
|
- ajout de nouvelles vues :
|
||||||
|
- Marchés publics sans leurs titulaires : vue dédiée aux titulaires de marchés avec des données provenant du répertoire SIRENE
|
||||||
|
- Données sur les titulaires et géolocalisation : vue sans les titulaires pour analyser les nombres de marchés et les montants
|
||||||
|
- amélioration de la page d'accueil
|
||||||
|
- développement de la page "db" avec description des vues et liste des colonnes
|
||||||
|
- les codes APE sont cliquables
|
||||||
|
- ajout des mentions légales
|
||||||
|
- ajout d'un formulatire d'inscription à une lettre d'information
|
||||||
|
- correction de bugs :
|
||||||
|
- correction du format de certaines dates dans les données
|
||||||
|
|
||||||
|
### 1.0.0
|
||||||
|
|
||||||
|
- publication sur https://decp.info
|
||||||
|
- ajout d'une vue équivalente au format DECP réglementaire
|
||||||
|
- personnalisation de datasette
|
||||||
|
- script de conversion quotidien basé sur [dataflows](https://github.com/datahq/dataflows)
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
# decp.info
|
# decp.info
|
||||||
|
|
||||||
> v2.1.0
|
> v2.3.1
|
||||||
|
> Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
||||||
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
|
||||||
|
|
||||||
=> [decp.info](https://decp.info)
|
=> [decp.info](https://decp.info)
|
||||||
|
|
||||||
@@ -26,9 +25,11 @@ python run.py
|
|||||||
|
|
||||||
## Déploiement
|
## Déploiement
|
||||||
|
|
||||||
- **Production** (branche `main`, [decp.info](https://decp.info)) : déploiement manuel via un déclenchement de la Github Action [Déploiement](https://github.com/ColinMaudry/decp.info/actions/workflows/deploy.yaml).
|
- **Production** (branche `main`, [decp.info](https://decp.info)) : déploiement manuel via un déclenchement de la Github Action [Déploiement](https://github.com/ColinMaudry/decp.info/actions/workflows/deploy.yaml)
|
||||||
- **Test** (branche `dev`, [test.decp.info](https://test.decp.info)) : déploiement automatique à chaque push sur la branche `dev`, via la même Github Action.
|
- **Test** (branche `dev`, [test.decp.info](https://test.decp.info)) : déploiement automatique à chaque push sur la branche `dev`, via la même Github Action.
|
||||||
|
|
||||||
|
Ne pas oublier de mettre à jour les fichier .env.
|
||||||
|
|
||||||
## Liens connexes
|
## Liens connexes
|
||||||
|
|
||||||
- [decp-processing](https://github.com/ColinMaudry/decp-processing) (traitement et publication des données)
|
- [decp-processing](https://github.com/ColinMaudry/decp-processing) (traitement et publication des données)
|
||||||
@@ -36,76 +37,4 @@ python run.py
|
|||||||
|
|
||||||
## Notes de version
|
## Notes de version
|
||||||
|
|
||||||
#### 2.1.0
|
Voir [CHANGELOG](https://github.com/ColinMaudry/decp.info/blob/main/CHANGELOG.md).
|
||||||
|
|
||||||
- Ajout des vues [acheteur](https://decp.info/acheteurs/24350013900189) ([#28](https://github.com/ColinMaudry/decp.info/issues/28)), [titulaire](https://decp.info/titulaires/51903758414786) ([#35](https://github.com/ColinMaudry/decp.info/issues/35)) et [marché](https://decp.info/marches/532239472000482025S00004) ([#40](https://github.com/ColinMaudry/decp.info/issues/40)) 🔎
|
|
||||||
- Ajout des balises HTML meta Open Graph et Twitter ([#39](https://github.com/ColinMaudry/decp.info/issues/39)) pour de beaux aperçus de liens 🖼️
|
|
||||||
- Formulaire de contact ([#48](https://github.com/ColinMaudry/decp.info/issues/48)) 📨
|
|
||||||
- Nom de colonnes plus_agréables ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 💅
|
|
||||||
- Définition des colonnes quand vous passez votre souris sur les en-têtes ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 📖
|
|
||||||
- Affichage du numéro de version près du logo et lien vers ici 🤓
|
|
||||||
- Variables globales uniquement en lecture (😁)
|
|
||||||
|
|
||||||
##### 2.0.1 (23 septembre 2025)
|
|
||||||
|
|
||||||
- Bloquage du bouton de téléchargement si trop de lignes (+ 65000) [#38](https://github.com/ColinMaudry/decp.info/issues/38)
|
|
||||||
- Amélioration du script de déploiement (deploy.sh)
|
|
||||||
- Meilleures instructions d'installation et lancement
|
|
||||||
- Coquilles 🐚
|
|
||||||
|
|
||||||
### 2.0.0 (23 septembre 2025)
|
|
||||||
|
|
||||||
- détails des sources de données
|
|
||||||
- section "À propos" plus développée
|
|
||||||
- correction de bugs dans les filtres de la data table
|
|
||||||
|
|
||||||
#### 2.0.0-alpha
|
|
||||||
|
|
||||||
- Data table fonctionnelle
|
|
||||||
|
|
||||||
### 1.5.0 (28/01/2023
|
|
||||||
|
|
||||||
- fixation des dépendances Python pour plus de stabilité en cas de réinstallation (Pipfile)
|
|
||||||
|
|
||||||
#### 1.4.1 (14/06/2021)
|
|
||||||
|
|
||||||
- ajout des traductions des opérations de filtrage à toutes les vues, pas seulement /db/decp
|
|
||||||
|
|
||||||
### 1.4.0 (14/06/2021)
|
|
||||||
|
|
||||||
- traduction des opérations de filtrage (ex : contains => contient)
|
|
||||||
- élargissement des menus de filtrage
|
|
||||||
- correction du titre de la page des notes de versions
|
|
||||||
|
|
||||||
### 1.3.0 (03/06/2021)
|
|
||||||
|
|
||||||
- utilisation de noms de colonnes plus lisibles dans l'application
|
|
||||||
- suppression des références à la licence et aux données source sur la page d'accueil
|
|
||||||
- correction des liens vers le code source
|
|
||||||
- correction de l'indentation des puces dans les notes de version
|
|
||||||
|
|
||||||
### 1.2.0 (28/05/2021)
|
|
||||||
|
|
||||||
- ajout d'une page "Notes de version"
|
|
||||||
- meilleur lien pour la documentation des champs
|
|
||||||
- déplacement du code de decp.info depuis [ColinMaudry/decp-table-schema-utils](https://github.com/ColinMaudry/decp-table-schema-utils) vers [ColinMaudry/decp.info](https://github.com/ColinMaudry/decp.info)
|
|
||||||
|
|
||||||
### 1.1.0 (25/05/2021)
|
|
||||||
|
|
||||||
- ajout de nouvelles vues :
|
|
||||||
- Marchés publics sans leurs titulaires : vue dédiée aux titulaires de marchés avec des données provenant du répertoire SIRENE
|
|
||||||
- Données sur les titulaires et géolocalisation : vue sans les titulaires pour analyser les nombres de marchés et les montants
|
|
||||||
- amélioration de la page d'accueil
|
|
||||||
- développement de la page "db" avec description des vues et liste des colonnes
|
|
||||||
- les codes APE sont cliquables
|
|
||||||
- ajout des mentions légales
|
|
||||||
- ajout d'un formulatire d'inscription à une lettre d'information
|
|
||||||
- correction de bugs :
|
|
||||||
- correction du format de certaines dates dans les données
|
|
||||||
|
|
||||||
### 1.0.0
|
|
||||||
|
|
||||||
- publication sur https://decp.info
|
|
||||||
- ajout d'une vue équivalente au format DECP réglementaire
|
|
||||||
- personnalisation de datasette
|
|
||||||
- script de conversion quotidien basé sur [dataflows](https://github.com/datahq/dataflows)
|
|
||||||
|
|||||||
+5
-4
@@ -1,13 +1,13 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "decp.info"
|
name = "decp.info"
|
||||||
description = "Interface d'exploration et d'analyse des marchés publics français."
|
description = "Interface d'exploration et d'analyse des marchés publics français."
|
||||||
version = "2.1.0"
|
version = "2.3.1"
|
||||||
requires-python = ">= 3.10"
|
requires-python = ">= 3.10"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
|
{ name = "Colin Maudry", email = "colin@colmo.tech" }
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dash==3.2.0",
|
"dash==3.3.0",
|
||||||
"dash[compress]",
|
"dash[compress]",
|
||||||
"polars",
|
"polars",
|
||||||
"gunicorn",
|
"gunicorn",
|
||||||
@@ -16,7 +16,8 @@ dependencies = [
|
|||||||
"xlsxwriter",
|
"xlsxwriter",
|
||||||
"plotly[express]",
|
"plotly[express]",
|
||||||
"httpx",
|
"httpx",
|
||||||
"pandas" # utilisé pour la création de certains graphiques
|
"pandas", # utilisé pour la création de certains graphiques
|
||||||
|
"unidecode"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|||||||
+6
-1
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
import dash_bootstrap_components as dbc
|
import dash_bootstrap_components as dbc
|
||||||
import tomllib
|
import tomllib
|
||||||
@@ -82,7 +83,7 @@ app.layout = html.Div(
|
|||||||
html.P(
|
html.P(
|
||||||
children=html.A(
|
children=html.A(
|
||||||
version,
|
version,
|
||||||
href="https://github.com/ColinMaudry/decp.info?tab=readme-ov-file#notes-de-version",
|
href="https://github.com/ColinMaudry/decp.info/blob/main/CHANGELOG.md",
|
||||||
target="_blank",
|
target="_blank",
|
||||||
),
|
),
|
||||||
className="version",
|
className="version",
|
||||||
@@ -90,6 +91,10 @@ app.layout = html.Div(
|
|||||||
],
|
],
|
||||||
className="logo",
|
className="logo",
|
||||||
),
|
),
|
||||||
|
html.Div(
|
||||||
|
id="announcements",
|
||||||
|
children=dcc.Markdown(os.getenv("ANNOUNCEMENTS")),
|
||||||
|
),
|
||||||
html.Div(
|
html.Div(
|
||||||
[
|
[
|
||||||
dcc.Link(
|
dcc.Link(
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="copy" class="svg-inline--fa fa-copy fa-w-14 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 738 B |
Binary file not shown.
|
After Width: | Height: | Size: 333 KiB |
+63
-11
@@ -53,9 +53,10 @@ div.logo > a {
|
|||||||
|
|
||||||
/* Réduire la taille du texte de la colonne Objet */
|
/* Réduire la taille du texte de la colonne Objet */
|
||||||
|
|
||||||
td[data-dash-column="objet"] {
|
/*
|
||||||
|
td[data-dash-column="objet"],td[data-dash-column="titulaire_nom"],td[data-dash-column="acheteur_nom"], {
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/* Couleur des en-têtes */
|
/* Couleur des en-têtes */
|
||||||
.dash-table-container
|
.dash-table-container
|
||||||
@@ -64,7 +65,7 @@ td[data-dash-column="objet"] {
|
|||||||
th.dash-header {
|
th.dash-header {
|
||||||
background-color: #b33821;
|
background-color: #b33821;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ td[data-dash-column="objet"] {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
text-wrap: wrap;
|
text-wrap: wrap;
|
||||||
font-family: sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Menu de masquage des colonnes */
|
/* Menu de masquage des colonnes */
|
||||||
@@ -130,11 +131,17 @@ td[data-dash-column="objet"] {
|
|||||||
|
|
||||||
/* Alternance des couleurs pour les lignes */
|
/* Alternance des couleurs pour les lignes */
|
||||||
.marches_table {
|
.marches_table {
|
||||||
font-family: sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.marches_table.stuck {
|
||||||
|
position: relative;
|
||||||
|
right: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
.marches_table .cell-table tr:nth-child(even) td {
|
.marches_table .cell-table tr:nth-child(even) td {
|
||||||
background-color: #feeeee;
|
background-color: #feeeee;
|
||||||
font-family: sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
#header > *,
|
#header > *,
|
||||||
@@ -142,6 +149,49 @@ td[data-dash-column="objet"] {
|
|||||||
margin: 0 0 20px 20px;
|
margin: 0 0 20px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Annonces */
|
||||||
|
#announcements {
|
||||||
|
margin-top: 25px;
|
||||||
|
max-width: 30%;
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page de recherche */
|
||||||
|
|
||||||
|
.tagline {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 120%;
|
||||||
|
display: block;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search {
|
||||||
|
margin: 30px auto 0px auto;
|
||||||
|
width: 500px;
|
||||||
|
font-size: 16px;
|
||||||
|
height: 30px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search_options {
|
||||||
|
margin: 16px auto;
|
||||||
|
width: 450px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search_options input {
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results_acheteur {
|
||||||
|
grid-column: 1;
|
||||||
|
grid-row: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results_titulaire {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Menu de navigation */
|
/* Menu de navigation */
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
@@ -168,10 +218,10 @@ summary > h3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#_pages_content {
|
#_pages_content {
|
||||||
padding-top: 28px;
|
padding: 28px 24px 0 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vue acheteur/titulaire */
|
/* Vue acheteur/titulaire/recherche */
|
||||||
.wrapper {
|
.wrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
@@ -179,9 +229,6 @@ summary > h3 {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wrapper > div {
|
|
||||||
}
|
|
||||||
|
|
||||||
.org_title {
|
.org_title {
|
||||||
grid-column: 1 / 3;
|
grid-column: 1 / 3;
|
||||||
grid-row: 1;
|
grid-row: 1;
|
||||||
@@ -211,6 +258,11 @@ summary > h3 {
|
|||||||
grid-row: 2;
|
grid-row: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.org_top {
|
||||||
|
grid-column: 1/3;
|
||||||
|
grid-row: 3;
|
||||||
|
}
|
||||||
|
|
||||||
/* Vue marché */
|
/* Vue marché */
|
||||||
|
|
||||||
.marche_infos p {
|
.marche_infos p {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import polars as pl
|
||||||
|
from dash import html
|
||||||
|
|
||||||
|
from src.figures import DataTable
|
||||||
|
from utils import add_links_in_dict, format_values, setup_table_columns
|
||||||
|
|
||||||
|
|
||||||
|
def get_top_org_table(data, org_type: str):
|
||||||
|
dff = pl.DataFrame(data, strict=False, infer_schema_length=5000)
|
||||||
|
if dff.height == 0:
|
||||||
|
return html.Div()
|
||||||
|
|
||||||
|
dff = dff.select(
|
||||||
|
["uid", f"{org_type}_id", f"{org_type}_nom", "distance", "montant"]
|
||||||
|
)
|
||||||
|
dff_nb = dff.group_by(f"{org_type}_id", f"{org_type}_nom", "distance").agg(
|
||||||
|
pl.len().alias("Attributions"), pl.sum("montant").alias("montant")
|
||||||
|
)
|
||||||
|
dff_nb = dff_nb.sort(by="montant", descending=True, nulls_last=True)
|
||||||
|
dff_nb = dff_nb.cast(pl.String)
|
||||||
|
dff_nb = dff_nb.fill_null("")
|
||||||
|
dff_nb = format_values(dff_nb)
|
||||||
|
columns, tooltip = setup_table_columns(
|
||||||
|
dff_nb, hideable=False, exclude=[f"{org_type}_id"]
|
||||||
|
)
|
||||||
|
data = dff_nb.to_dicts()
|
||||||
|
data = add_links_in_dict(data, f"{org_type}")
|
||||||
|
|
||||||
|
return DataTable(
|
||||||
|
dtid=f"top10_{org_type}",
|
||||||
|
data=data,
|
||||||
|
page_action="native",
|
||||||
|
page_size=10,
|
||||||
|
columns=columns,
|
||||||
|
tooltip_header=tooltip,
|
||||||
|
)
|
||||||
+75
-6
@@ -1,11 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
import plotly.express as px
|
import plotly.express as px
|
||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import dash_table, dcc, html
|
from dash import dash_table, dcc, html
|
||||||
|
|
||||||
|
|
||||||
def get_map_count_marches(lf: pl.LazyFrame):
|
def get_map_count_marches(df: pl.DataFrame):
|
||||||
|
lf = df.lazy()
|
||||||
lf = lf.with_columns(
|
lf = lf.with_columns(
|
||||||
pl.col("lieuExecution_code").str.head(2).str.zfill(2).alias("Département")
|
pl.col("lieuExecution_code").str.head(2).str.zfill(2).alias("Département")
|
||||||
)
|
)
|
||||||
@@ -26,7 +28,7 @@ def get_map_count_marches(lf: pl.LazyFrame):
|
|||||||
for f in departements["features"]:
|
for f in departements["features"]:
|
||||||
f["id"] = f["properties"]["code"]
|
f["id"] = f["properties"]["code"]
|
||||||
|
|
||||||
df = lf.collect()
|
df = lf.collect(engine="streaming")
|
||||||
|
|
||||||
fig = px.choropleth(
|
fig = px.choropleth(
|
||||||
df,
|
df,
|
||||||
@@ -38,8 +40,8 @@ def get_map_count_marches(lf: pl.LazyFrame):
|
|||||||
range_color=(df["uid"].min(), df["uid"].max()),
|
range_color=(df["uid"].min(), df["uid"].max()),
|
||||||
labels={"uid": "Marchés attribués"},
|
labels={"uid": "Marchés attribués"},
|
||||||
scope="europe",
|
scope="europe",
|
||||||
width=1000,
|
width=900,
|
||||||
height=800,
|
height=700,
|
||||||
)
|
)
|
||||||
|
|
||||||
fig.update_geos(fitbounds="locations", visible=False)
|
fig.update_geos(fitbounds="locations", visible=False)
|
||||||
@@ -54,7 +56,8 @@ def get_map_count_marches(lf: pl.LazyFrame):
|
|||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
def get_barchart_sources(lf: pl.LazyFrame, type_date: str):
|
def get_barchart_sources(df: pl.DataFrame, type_date: str):
|
||||||
|
lf = df.lazy()
|
||||||
labels = {
|
labels = {
|
||||||
"dateNotification": "notification",
|
"dateNotification": "notification",
|
||||||
"datePublicationDonnees": "publication des données",
|
"datePublicationDonnees": "publication des données",
|
||||||
@@ -97,7 +100,7 @@ def get_barchart_sources(lf: pl.LazyFrame, type_date: str):
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
lf = lf.sort(by=["sourceDataset"], descending=False)
|
lf = lf.sort(by=["sourceDataset"], descending=False)
|
||||||
df: pl.DataFrame = lf.collect()
|
df: pl.DataFrame = lf.collect(engine="streaming")
|
||||||
|
|
||||||
fig = px.bar(
|
fig = px.bar(
|
||||||
df,
|
df,
|
||||||
@@ -190,3 +193,69 @@ def point_on_map(lat, lon):
|
|||||||
|
|
||||||
graph = dcc.Graph(id="map", figure=fig)
|
graph = dcc.Graph(id="map", figure=fig)
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
|
|
||||||
|
class DataTable(dash_table.DataTable):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
dtid: str,
|
||||||
|
hidden_columns: list = None,
|
||||||
|
data=None,
|
||||||
|
columns: list = None,
|
||||||
|
page_size: int = 20,
|
||||||
|
page_action: Literal["native", "custom", "none"] = "native",
|
||||||
|
sort_action: Literal["native", "custom", "none"] = "native",
|
||||||
|
filter_action: Literal["native", "custom", "none"] = "native",
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
|
# Styles de base
|
||||||
|
style_cell_conditional = [
|
||||||
|
{
|
||||||
|
"if": {"column_id": "objet"},
|
||||||
|
"minWidth": "350px",
|
||||||
|
"textAlign": "left",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"lineHeight": "18px",
|
||||||
|
"whiteSpace": "normal",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": {"column_id": "acheteur_nom"},
|
||||||
|
"minWidth": "250px",
|
||||||
|
"textAlign": "left",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"lineHeight": "18px",
|
||||||
|
"whiteSpace": "normal",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": {"column_id": "titulaire_nom"},
|
||||||
|
"minWidth": "250px",
|
||||||
|
"textAlign": "left",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"lineHeight": "18px",
|
||||||
|
"whiteSpace": "normal",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Initialisation de la classe parente avec les arguments
|
||||||
|
super().__init__(
|
||||||
|
id=dtid,
|
||||||
|
data=data,
|
||||||
|
columns=columns,
|
||||||
|
cell_selectable=False,
|
||||||
|
page_size=page_size,
|
||||||
|
filter_action=filter_action,
|
||||||
|
page_action=page_action,
|
||||||
|
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
||||||
|
sort_action=sort_action,
|
||||||
|
sort_mode="multi",
|
||||||
|
sort_by=[],
|
||||||
|
row_deletable=False,
|
||||||
|
page_current=0,
|
||||||
|
style_cell_conditional=style_cell_conditional,
|
||||||
|
data_timestamp=0,
|
||||||
|
markdown_options={"html": True},
|
||||||
|
tooltip_duration=8000,
|
||||||
|
tooltip_delay=350,
|
||||||
|
hidden_columns=hidden_columns,
|
||||||
|
**kwargs, # Possibilité de remplacer des arguments
|
||||||
|
)
|
||||||
|
|||||||
@@ -36,13 +36,23 @@ les fonctionnalités actuelles de decp.info. Il est ainsi possible de rajouter
|
|||||||
- des alertes par email si des marchés correspondant à certains critères
|
- des alertes par email si des marchés correspondant à certains critères
|
||||||
- le développement d'une API pour alimenter d'autres logiciels
|
- le développement d'une API pour alimenter d'autres logiciels
|
||||||
- ...et toutes les fonctionnalités auxquelles vous pourrez penser
|
- ...et toutes les fonctionnalités auxquelles vous pourrez penser
|
||||||
|
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
|
html.H4("Contact", id="contact"),
|
||||||
|
dcc.Markdown("""
|
||||||
|
|
||||||
|
- Email : [colin@colmo.tech](mailto:colin@colmo.tech)
|
||||||
|
- Bluesky : [@col1m.bsky.social](https://bsky.app/profile/col1m.bsky.social)
|
||||||
|
- Mastodon : [col1m@mamot.fr](https://mamot.fr/@col1m)
|
||||||
|
- LinkedIn : [colinmaudry](https://www.linkedin.com/in/colinmaudry/)
|
||||||
|
|
||||||
|
"""),
|
||||||
html.H4("Pour contribuer", id="contribuer"),
|
html.H4("Pour contribuer", id="contribuer"),
|
||||||
dcc.Markdown("""
|
dcc.Markdown("""
|
||||||
- via l'achat d'une prestation de service (devis, prestation, facture), vous pouvez financer le développement de [fonctionnalités prévues](https://github.com/ColinMaudry/decp.info/issues), ou d'autres !
|
- via l'achat d'une prestation de service (devis, prestation, facture), vous pouvez financer le développement de [fonctionnalités prévues](https://github.com/ColinMaudry/decp.info/issues), ou d'autres !
|
||||||
- ma société accepte aussi les dons (pas de réduction d'impôt possible)
|
- ma société accepte aussi les dons (pas de réduction d'impôt possible)
|
||||||
- [écrivez-moi](/contact) et on discute !
|
- écrivez-moi et on discute !
|
||||||
|
|
||||||
#### Pour explorer le projet
|
#### Pour explorer le projet
|
||||||
|
|
||||||
@@ -54,7 +64,20 @@ les fonctionnalités actuelles de decp.info. Il est ainsi possible de rajouter
|
|||||||
- [de decp.info](https://github.com/ColinMaudry/decp.info)
|
- [de decp.info](https://github.com/ColinMaudry/decp.info)
|
||||||
- [du traitement des données](https://github.com/ColinMaudry/decp-processing)
|
- [du traitement des données](https://github.com/ColinMaudry/decp-processing)
|
||||||
"""),
|
"""),
|
||||||
html.H4("Sources de données", id="sources"),
|
html.H4("Qualité et exhaustivité des données", id="qualite-exhausitivite"),
|
||||||
|
dcc.Markdown("""Les données visibles sur ce site proviennent exclusivement de la publication de données ouvertes par les acheteurs publics ou en leur nom, régie par [l'arrêté du 22 décembre 2022](https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000046850496). Leur qualité est donc principalement liée à la qualité de leur saisie par les agents publics, parfois peu aidé·es par la qualité des outils à leur disposition. Je pense que l'analyse de marchés individuels et le comptage de marchés sur des critères autres que financiers sont plutôt fiables. En revanche, certains montants de marché estimés à des valeurs farfelues ([1 euro](https://decp.info/marches/432766947000192025S01301), [1 milliard](https://decp.info/marches/2459004280001320210000000271)) faussent les calculs par aggrégation (sommes, moyennes, médianes) et donc la production de statistiques financières fiables. Acheteurs, acheteuses : s'il vous plaît, essayez d'estimer les montants des marchés publics attribués de manière plus précise.
|
||||||
|
|
||||||
|
Quant à l'exhaustivité, je consolide toutes les sources de données exploitables que j'ai pu identifier (voir [statistiques](/statistiques)). Certains profils d'acheteurs ne publient pas leurs données malgré l'obligation réglementaire :
|
||||||
|
|
||||||
|
- marches-securises.fr
|
||||||
|
- klekoon.fr (ils y travaillent)
|
||||||
|
|
||||||
|
**marches-publics.gouv.fr** (PLACE, [AIFE](https://aife.economie.gouv.fr)), la plateforme des marchés de l'État, ne publie plus de données depuis le 1er janvier 2024 et l'entrée en vigueur de l'arrêté. Nous n'avons donc plus de données sur les marchés publics passés par les ministères, ainsi que sur ceux passés par les acheteurs clients d'[achatpublic.com](https://www.achatpublic.com), qui s'appuie sur les moyens de publication de l'AIFE.
|
||||||
|
|
||||||
|
**marches-publics.info** (AWS) publie ses données de manière assez sporadique depuis début 2023. Compte tenu de son poids dans le secteur, c'est assez dommageable pour la transparence des marchés publics.
|
||||||
|
|
||||||
|
Au milieu de ces mauvaises nouvelles, je tiens à souligner la belle continuité de la publication par la DGFiP des données des marchés publics remontées via le [protocole PES](https://www.collectivites-locales.gouv.fr/finances-locales/le-protocole-dechange-standard-pes). Merci à leurs équipes."""),
|
||||||
|
html.H4("Sources de données ", id="qualite-exhausitivite"),
|
||||||
get_sources_tables(os.getenv("SOURCE_STATS_CSV_PATH")),
|
get_sources_tables(os.getenv("SOURCE_STATS_CSV_PATH")),
|
||||||
html.H4("Mentions légales", id="mentions-legales"),
|
html.H4("Mentions légales", id="mentions-legales"),
|
||||||
dcc.Markdown("""
|
dcc.Markdown("""
|
||||||
+134
-87
@@ -1,18 +1,21 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import Input, Output, State, callback, dash_table, dcc, html, register_page
|
from dash import Input, Output, State, callback, dcc, html, register_page
|
||||||
|
|
||||||
from src.figures import point_on_map
|
from src.callbacks import get_top_org_table
|
||||||
|
from src.figures import DataTable, point_on_map
|
||||||
from src.utils import (
|
from src.utils import (
|
||||||
add_links_in_dict,
|
df,
|
||||||
format_montant,
|
filter_table_data,
|
||||||
format_number,
|
format_number,
|
||||||
get_annuaire_data,
|
get_annuaire_data,
|
||||||
|
get_button_properties,
|
||||||
|
get_default_hidden_columns,
|
||||||
get_departement_region,
|
get_departement_region,
|
||||||
lf,
|
|
||||||
meta_content,
|
meta_content,
|
||||||
setup_table_columns,
|
prepare_table_data,
|
||||||
|
sort_table_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
@@ -25,11 +28,22 @@ register_page(
|
|||||||
order=5,
|
order=5,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
datatable = html.Div(
|
||||||
|
className="marches_table",
|
||||||
|
children=DataTable(
|
||||||
|
dtid="acheteur_datatable",
|
||||||
|
page_action="custom",
|
||||||
|
filter_action="custom",
|
||||||
|
sort_action="custom",
|
||||||
|
page_size=10,
|
||||||
|
hidden_columns=get_default_hidden_columns(page="acheteur"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
dcc.Store(id="acheteur_data", storage_type="memory"),
|
dcc.Store(id="acheteur_data", storage_type="memory"),
|
||||||
dcc.Location(id="url", refresh="callback-nav"),
|
dcc.Location(id="url", refresh="callback-nav"),
|
||||||
html.Div(
|
html.Div(
|
||||||
className="container",
|
|
||||||
children=[
|
children=[
|
||||||
html.Div(
|
html.Div(
|
||||||
className="wrapper",
|
className="wrapper",
|
||||||
@@ -83,17 +97,43 @@ layout = [
|
|||||||
html.P(id="acheteur_titulaires_differents"),
|
html.P(id="acheteur_titulaires_differents"),
|
||||||
html.Button(
|
html.Button(
|
||||||
"Téléchargement au format Excel",
|
"Téléchargement au format Excel",
|
||||||
id="btn-download-acheteur-data",
|
id="btn-download-data-acheteur",
|
||||||
),
|
),
|
||||||
dcc.Download(id="download-acheteur-data"),
|
dcc.Download(id="download-data-acheteur"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
html.Div(className="org_map", id="acheteur_map"),
|
html.Div(className="org_map", id="acheteur_map"),
|
||||||
|
html.Div(
|
||||||
|
className="org_top",
|
||||||
|
children=[
|
||||||
|
html.H3("Top titulaires"),
|
||||||
|
html.Div(className="marches_table", id="top10_titulaires"),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
# récupérer les données de l'acheteur sur l'api annuaire
|
# récupérer les données de l'acheteur sur l'api annuaire
|
||||||
html.H3("Derniers marchés publics attribués"),
|
html.H3("Derniers marchés publics attribués"),
|
||||||
html.Div(id="acheteur_last_marches", children=""),
|
dcc.Loading(
|
||||||
|
overlay_style={"visibility": "visible", "filter": "blur(2px)"},
|
||||||
|
id="loading-home",
|
||||||
|
type="default",
|
||||||
|
children=[
|
||||||
|
html.Div(
|
||||||
|
[
|
||||||
|
html.P("lignes", id="acheteur_nb_rows"),
|
||||||
|
html.Button(
|
||||||
|
"Téléchargement désactivé au-delà de 65 000 lignes",
|
||||||
|
id="btn-download-filtered-data-acheteur",
|
||||||
|
disabled=True,
|
||||||
|
),
|
||||||
|
dcc.Download(id="acheteur-download-filtered-data"),
|
||||||
|
],
|
||||||
|
className="table-menu",
|
||||||
|
),
|
||||||
|
datatable,
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -146,113 +186,84 @@ def update_acheteur_infos(url):
|
|||||||
Input(component_id="acheteur_data", component_property="data"),
|
Input(component_id="acheteur_data", component_property="data"),
|
||||||
)
|
)
|
||||||
def update_acheteur_stats(data):
|
def update_acheteur_stats(data):
|
||||||
df = pl.DataFrame(data)
|
dff = pl.DataFrame(data, strict=False, infer_schema_length=5000)
|
||||||
if df.height == 0:
|
if dff.height == 0:
|
||||||
df = pl.DataFrame(schema=lf.collect_schema())
|
dff = pl.DataFrame(schema=df.collect_schema())
|
||||||
df_marches = df.unique("id")
|
df_marches = dff.unique("id")
|
||||||
nb_marches = format_number(df_marches.height)
|
nb_marches = format_number(df_marches.height)
|
||||||
# somme_marches = format_number(int(df_marches.select(pl.sum("montant")).item()))
|
# somme_marches = format_number(int(df_marches.select(pl.sum("montant")).item()))
|
||||||
marches_attribues = [html.Strong(nb_marches), " marchés et accord-cadres attribués"]
|
marches_attribues = [html.Strong(nb_marches), " marchés et accord-cadres attribués"]
|
||||||
# + ", pour un total de ", html.Strong(somme_marches + " €")]
|
# + ", pour un total de ", html.Strong(somme_marches + " €")]
|
||||||
del df_marches
|
del df_marches
|
||||||
|
|
||||||
nb_titulaires = df.unique("titulaire_id").height
|
nb_titulaires = dff.unique("titulaire_id").height
|
||||||
nb_titulaires = [
|
nb_titulaires = [
|
||||||
html.Strong(format_number(nb_titulaires)),
|
html.Strong(format_number(nb_titulaires)),
|
||||||
" titulaires (SIRET) différents",
|
" titulaires (SIRET) différents",
|
||||||
]
|
]
|
||||||
del df
|
del dff
|
||||||
|
|
||||||
return marches_attribues, nb_titulaires
|
return marches_attribues, nb_titulaires
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output(component_id="acheteur_data", component_property="data"),
|
Output(component_id="acheteur_data", component_property="data"),
|
||||||
|
Output("btn-download-data-acheteur", "disabled"),
|
||||||
|
Output("btn-download-data-acheteur", "children"),
|
||||||
|
Output("btn-download-data-acheteur", "title"),
|
||||||
Input(component_id="url", component_property="pathname"),
|
Input(component_id="url", component_property="pathname"),
|
||||||
Input(component_id="acheteur_year", component_property="value"),
|
Input(component_id="acheteur_year", component_property="value"),
|
||||||
)
|
)
|
||||||
def get_acheteur_marches_data(url, acheteur_year: str) -> pl.LazyFrame:
|
def get_acheteur_marches_data(url, acheteur_year: str) -> tuple:
|
||||||
acheteur_siret = url.split("/")[-1]
|
acheteur_siret = url.split("/")[-1]
|
||||||
lff = lf.filter(pl.col("acheteur_id") == acheteur_siret)
|
lff = df.lazy()
|
||||||
lff = lff.fill_null("")
|
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||||
lff = lff.select(
|
|
||||||
"id",
|
|
||||||
"uid",
|
|
||||||
"objet",
|
|
||||||
"dateNotification",
|
|
||||||
"titulaire_id",
|
|
||||||
"titulaire_typeIdentifiant",
|
|
||||||
"titulaire_nom",
|
|
||||||
"montant",
|
|
||||||
"codeCPV",
|
|
||||||
"dureeMois",
|
|
||||||
)
|
|
||||||
if acheteur_year and acheteur_year != "Toutes":
|
if acheteur_year and acheteur_year != "Toutes":
|
||||||
lff = lff.filter(
|
acheteur_year = int(acheteur_year)
|
||||||
pl.col("dateNotification").cast(pl.String).str.starts_with(acheteur_year)
|
lff = lff.filter(pl.col("dateNotification").dt.year() == acheteur_year)
|
||||||
)
|
lff = lff.sort(["dateNotification", "uid"], descending=True, nulls_last=True)
|
||||||
lff = lff.sort(["dateNotification", "id"], descending=True, nulls_last=True)
|
dff: pl.DataFrame = lff.collect(engine="streaming")
|
||||||
|
download_disabled, download_text, download_title = get_button_properties(dff.height)
|
||||||
|
|
||||||
data = lff.collect(engine="streaming").to_dicts()
|
data = dff.to_dicts()
|
||||||
return data
|
return data, download_disabled, download_text, download_title
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output(component_id="acheteur_last_marches", component_property="children"),
|
Output("acheteur_datatable", "data"),
|
||||||
|
Output("acheteur_datatable", "columns"),
|
||||||
|
Output("acheteur_datatable", "tooltip_header"),
|
||||||
|
Output("acheteur_datatable", "data_timestamp"),
|
||||||
|
Output("acheteur_nb_rows", "children"),
|
||||||
|
Output("btn-download-filtered-data-acheteur", "disabled"),
|
||||||
|
Output("btn-download-filtered-data-acheteur", "children"),
|
||||||
|
Output("btn-download-filtered-data-acheteur", "title"),
|
||||||
|
Input("acheteur_data", "data"),
|
||||||
|
Input("acheteur_datatable", "page_current"),
|
||||||
|
Input("acheteur_datatable", "page_size"),
|
||||||
|
Input("acheteur_datatable", "filter_query"),
|
||||||
|
Input("acheteur_datatable", "sort_by"),
|
||||||
|
State("acheteur_datatable", "data_timestamp"),
|
||||||
|
)
|
||||||
|
def get_last_marches_data(
|
||||||
|
data, page_current, page_size, filter_query, sort_by, data_timestamp
|
||||||
|
) -> tuple:
|
||||||
|
return prepare_table_data(
|
||||||
|
data, data_timestamp, filter_query, page_current, page_size, sort_by
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output(component_id="top10_titulaires", component_property="children"),
|
||||||
Input(component_id="acheteur_data", component_property="data"),
|
Input(component_id="acheteur_data", component_property="data"),
|
||||||
)
|
)
|
||||||
def get_last_marches_table(data) -> html.Div:
|
def get_top_titulaires(data):
|
||||||
dff = pl.DataFrame(data)
|
return get_top_org_table(data, "titulaire")
|
||||||
dff = format_montant(dff)
|
|
||||||
columns, tooltip = setup_table_columns(
|
|
||||||
dff,
|
|
||||||
hideable=False,
|
|
||||||
exclude=["titulaire_id", "titulaire_typeIdentifiant", "uid"],
|
|
||||||
)
|
|
||||||
data = dff.to_dicts()
|
|
||||||
data = add_links_in_dict(data, "titulaire")
|
|
||||||
|
|
||||||
table = html.Div(
|
|
||||||
className="marches_table",
|
|
||||||
id="acheteur_datatable",
|
|
||||||
children=dash_table.DataTable(
|
|
||||||
data=data,
|
|
||||||
markdown_options={"html": True},
|
|
||||||
page_action="native",
|
|
||||||
filter_action="native",
|
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
|
||||||
columns=columns,
|
|
||||||
tooltip_header=tooltip,
|
|
||||||
tooltip_duration=8000,
|
|
||||||
tooltip_delay=350,
|
|
||||||
cell_selectable=False,
|
|
||||||
page_size=10,
|
|
||||||
style_cell_conditional=[
|
|
||||||
{
|
|
||||||
"if": {"column_id": "objet"},
|
|
||||||
"minWidth": "300px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "14px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"if": {"column_id": "titulaire_nom"},
|
|
||||||
"minWidth": "200px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "18px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return table
|
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output("download-acheteur-data", "data"),
|
Output("download-data-acheteur", "data"),
|
||||||
Input("btn-download-acheteur-data", "n_clicks"),
|
Input("btn-download-data-acheteur", "n_clicks"),
|
||||||
State(component_id="acheteur_data", component_property="data"),
|
State(component_id="acheteur_data", component_property="data"),
|
||||||
State(component_id="acheteur_nom", component_property="children"),
|
State(component_id="acheteur_nom", component_property="children"),
|
||||||
State(component_id="acheteur_year", component_property="value"),
|
State(component_id="acheteur_year", component_property="value"),
|
||||||
@@ -273,3 +284,39 @@ def download_acheteur_data(
|
|||||||
|
|
||||||
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
return dcc.send_bytes(to_bytes, filename=f"decp_{acheteur_nom}_{date}.xlsx")
|
return dcc.send_bytes(to_bytes, filename=f"decp_{acheteur_nom}_{date}.xlsx")
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("acheteur-download-filtered-data", "data"),
|
||||||
|
State("acheteur_data", "data"),
|
||||||
|
Input("btn-download-filtered-data-acheteur", "n_clicks"),
|
||||||
|
State("acheteur_nom", "children"),
|
||||||
|
State("acheteur_datatable", "filter_query"),
|
||||||
|
State("acheteur_datatable", "sort_by"),
|
||||||
|
State("acheteur_datatable", "hidden_columns"),
|
||||||
|
prevent_initial_call=True,
|
||||||
|
)
|
||||||
|
def download_filtered_acheteur_data(
|
||||||
|
data, n_clicks, acheteur_nom, filter_query, sort_by, hidden_columns: list = None
|
||||||
|
):
|
||||||
|
lff: pl.LazyFrame = pl.LazyFrame(
|
||||||
|
data
|
||||||
|
) # start from the full acheteur data, not from paginated table data
|
||||||
|
|
||||||
|
# Les colonnes masquées sont supprimées
|
||||||
|
if hidden_columns:
|
||||||
|
lff = lff.drop(hidden_columns)
|
||||||
|
|
||||||
|
if filter_query:
|
||||||
|
lff = filter_table_data(lff, filter_query)
|
||||||
|
|
||||||
|
if len(sort_by) > 0:
|
||||||
|
lff = sort_table_data(lff, sort_by)
|
||||||
|
|
||||||
|
def to_bytes(buffer):
|
||||||
|
lff.collect(engine="streaming").write_excel(buffer, worksheet="DECP")
|
||||||
|
|
||||||
|
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
|
return dcc.send_bytes(
|
||||||
|
to_bytes, filename=f"decp_filtrées_{acheteur_nom}_{date}.xlsx"
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,170 +0,0 @@
|
|||||||
import os
|
|
||||||
import re
|
|
||||||
import smtplib
|
|
||||||
import time
|
|
||||||
from email.mime.multipart import MIMEMultipart
|
|
||||||
from email.mime.text import MIMEText
|
|
||||||
|
|
||||||
from dash import Input, Output, State, callback, dcc, html, register_page
|
|
||||||
from flask import request
|
|
||||||
|
|
||||||
from src.utils import meta_content
|
|
||||||
|
|
||||||
name = "Contact"
|
|
||||||
register_page(
|
|
||||||
__name__,
|
|
||||||
path="/contact",
|
|
||||||
title=meta_content["title"],
|
|
||||||
name=name,
|
|
||||||
description=meta_content["description"],
|
|
||||||
image_url=meta_content["image_url"],
|
|
||||||
order=6,
|
|
||||||
)
|
|
||||||
|
|
||||||
layout = html.Div(
|
|
||||||
className="container",
|
|
||||||
children=[
|
|
||||||
html.H2("Contact", id="contact"),
|
|
||||||
html.P(
|
|
||||||
"Votre message arrivera directement dans ma boîte mail, et je reviendrai vers vous rapidement."
|
|
||||||
),
|
|
||||||
html.Div(
|
|
||||||
[
|
|
||||||
html.Label("Votre nom"),
|
|
||||||
dcc.Input(
|
|
||||||
id="input-name",
|
|
||||||
type="text",
|
|
||||||
style={"width": "100%", "padding": "8px", "margin": "8px 0"},
|
|
||||||
),
|
|
||||||
html.Label("Votre adresse email"),
|
|
||||||
dcc.Input(
|
|
||||||
id="input-email",
|
|
||||||
type="email",
|
|
||||||
style={"width": "100%", "padding": "8px", "margin": "8px 0"},
|
|
||||||
),
|
|
||||||
html.Label("Message"),
|
|
||||||
dcc.Textarea(
|
|
||||||
id="input-message",
|
|
||||||
style={
|
|
||||||
"width": "100%",
|
|
||||||
"height": 200,
|
|
||||||
"padding": "8px",
|
|
||||||
"margin": "8px 0",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
html.Button(
|
|
||||||
"Envoyer ",
|
|
||||||
id="submit-button",
|
|
||||||
n_clicks=0,
|
|
||||||
style={"marginTop": "10px"},
|
|
||||||
),
|
|
||||||
html.Div(
|
|
||||||
id="output-message", style={"marginTop": "10px", "color": "green"}
|
|
||||||
),
|
|
||||||
],
|
|
||||||
style={
|
|
||||||
"maxWidth": "600px",
|
|
||||||
"margin": "auto",
|
|
||||||
"padding": "20px",
|
|
||||||
"lineHeight": "20px",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
dcc.Markdown("""
|
|
||||||
- Bluesky : [@col1m.bsky.social](https://bsky.app/profile/col1m.bsky.social)
|
|
||||||
- Mastodon : [col1m@mamot.fr](https://mamot.fr/@col1m)
|
|
||||||
- LinkedIn : [colinmaudry](https://www.linkedin.com/in/colinmaudry/)
|
|
||||||
- venez discuter de la transparence de la commande publique [sur le forum teamopendata.org](https://teamopendata.org/c/commande-publique/101)
|
|
||||||
"""),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
rate_limit_store = {} # {ip: last_timestamp}
|
|
||||||
RATE_LIMIT_WINDOW = 300 # 5 minutes
|
|
||||||
|
|
||||||
|
|
||||||
def is_rate_limited():
|
|
||||||
ip = request.remote_addr
|
|
||||||
now = time.time()
|
|
||||||
last_time = rate_limit_store.get(ip)
|
|
||||||
|
|
||||||
if last_time and (now - last_time) < RATE_LIMIT_WINDOW:
|
|
||||||
return True # rate limited !
|
|
||||||
rate_limit_store[ip] = now # màj du timestamp
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def sanitize_email(email):
|
|
||||||
return re.match(r"[^@]+@[^@]+\.[^@]+", email)
|
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
|
||||||
Output("output-message", "children"),
|
|
||||||
Input("submit-button", "n_clicks"),
|
|
||||||
State("input-name", "value"),
|
|
||||||
State("input-email", "value"),
|
|
||||||
State("input-message", "value"),
|
|
||||||
prevent_initial_call=True,
|
|
||||||
)
|
|
||||||
def send_email(n_clicks, form_name, form_email, form_message):
|
|
||||||
if not all([form_name, form_email, form_message]):
|
|
||||||
return html.Div(
|
|
||||||
"Veuillez s'il vous plaît remplir tous les champs.", style={"color": "red"}
|
|
||||||
)
|
|
||||||
|
|
||||||
client_ip = request.remote_addr
|
|
||||||
if is_rate_limited():
|
|
||||||
wait_time = int(RATE_LIMIT_WINDOW - (time.time() - rate_limit_store[client_ip]))
|
|
||||||
return html.Div(
|
|
||||||
f"⏳ J'ai mis en place une protection contre le spam, et vous m'avez écrit il y a moins de 5 minutes. "
|
|
||||||
f"Veuillez s'il vous plaît attendre {wait_time} secondes avant de renvoyer un message.",
|
|
||||||
style={"color": "black"},
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Configuration du serveur SMTP
|
|
||||||
smtp_server = os.getenv("SENDER_SERVER_DOMAIN")
|
|
||||||
smtp_port = 587
|
|
||||||
login_email = os.getenv("LOGIN_EMAIL")
|
|
||||||
from_email = os.getenv("FROM_EMAIL")
|
|
||||||
to_email = os.getenv("TO_EMAIL", from_email)
|
|
||||||
login_password = os.getenv("LOGIN_PASSWORD")
|
|
||||||
|
|
||||||
print(
|
|
||||||
smtp_server,
|
|
||||||
smtp_port,
|
|
||||||
login_email,
|
|
||||||
from_email,
|
|
||||||
to_email,
|
|
||||||
login_password,
|
|
||||||
sep="\n",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Création de l'email
|
|
||||||
email = MIMEMultipart()
|
|
||||||
email["From"] = from_email
|
|
||||||
email["To"] = to_email
|
|
||||||
email["Subject"] = f"[decp.info] Message de {form_name}"
|
|
||||||
|
|
||||||
body = f"""
|
|
||||||
Nom : {form_name}
|
|
||||||
Email : {form_email}
|
|
||||||
|
|
||||||
Message :
|
|
||||||
{form_message}
|
|
||||||
"""
|
|
||||||
email.attach(MIMEText(body, "plain"))
|
|
||||||
|
|
||||||
# Send email
|
|
||||||
server = smtplib.SMTP(smtp_server, smtp_port)
|
|
||||||
server.starttls()
|
|
||||||
server.login(login_email, login_password)
|
|
||||||
server.sendmail(from_email, to_email, email.as_string())
|
|
||||||
server.quit()
|
|
||||||
|
|
||||||
return html.Div("✅ Envoi réussi", style={"color": "green"})
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
return html.Div(
|
|
||||||
f"❌ Échec de l'envoi du message : {str(e)}", style={"color": "red"}
|
|
||||||
)
|
|
||||||
+9
-13
@@ -4,7 +4,7 @@ import polars as pl
|
|||||||
from dash import Input, Output, callback, dcc, html, register_page
|
from dash import Input, Output, callback, dcc, html, register_page
|
||||||
from polars import selectors as cs
|
from polars import selectors as cs
|
||||||
|
|
||||||
from src.utils import data_schema, format_montant, lf, meta_content
|
from src.utils import data_schema, df, format_values, meta_content
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
__name__,
|
__name__,
|
||||||
@@ -62,22 +62,20 @@ layout = [
|
|||||||
Output("titulaires_data", "data"),
|
Output("titulaires_data", "data"),
|
||||||
Input(component_id="url", component_property="pathname"),
|
Input(component_id="url", component_property="pathname"),
|
||||||
)
|
)
|
||||||
def get_marche_data(url):
|
def get_marche_data(url) -> tuple[dict, list]:
|
||||||
marche_uid = url.split("/")[-1]
|
marche_uid = url.split("/")[-1]
|
||||||
|
|
||||||
# Récupération des données du marché à partir du lf global
|
# Récupération des données du marché à partir du df global
|
||||||
lff = lf.filter(pl.col("uid") == pl.lit(marche_uid))
|
|
||||||
|
lff = df.lazy()
|
||||||
|
lff = lff.filter(pl.col("uid") == pl.lit(marche_uid))
|
||||||
|
|
||||||
# Données des titulaires du marché
|
# Données des titulaires du marché
|
||||||
dff_titulaires = lff.select(cs.starts_with("titulaire")).collect(engine="streaming")
|
dff_titulaires = lff.select(cs.starts_with("titulaire")).collect(engine="streaming")
|
||||||
|
|
||||||
# Données du marché
|
# Données du marché
|
||||||
dff_marche = (
|
dff_marche = lff.unique("uid").collect(engine="streaming")
|
||||||
lff.select(~cs.starts_with("titulaires")).unique().collect(engine="streaming")
|
dff_marche = format_values(dff_marche)
|
||||||
)
|
|
||||||
dff_marche = format_montant(dff_marche)
|
|
||||||
|
|
||||||
assert dff_marche.height == 1
|
|
||||||
|
|
||||||
return dff_marche.to_dicts()[0], dff_titulaires.to_dicts()
|
return dff_marche.to_dicts()[0], dff_titulaires.to_dicts()
|
||||||
|
|
||||||
@@ -92,7 +90,7 @@ def get_marche_data(url):
|
|||||||
def update_marche_info(marche, titulaires):
|
def update_marche_info(marche, titulaires):
|
||||||
def make_parameter(col):
|
def make_parameter(col):
|
||||||
column_object = data_schema.get(col)
|
column_object = data_schema.get(col)
|
||||||
column_name = column_object.get("friendly_name") if column_object else col
|
column_name = column_object.get("title") if column_object else col
|
||||||
|
|
||||||
if marche[col]:
|
if marche[col]:
|
||||||
if col == "acheteur_nom":
|
if col == "acheteur_nom":
|
||||||
@@ -108,8 +106,6 @@ def update_marche_info(marche, titulaires):
|
|||||||
|
|
||||||
# Dates
|
# Dates
|
||||||
elif col in ["dateNotification", "datePublicationDonnees"]:
|
elif col in ["dateNotification", "datePublicationDonnees"]:
|
||||||
print(marche[col])
|
|
||||||
|
|
||||||
value = datetime.fromisoformat(marche[col]).strftime("%d/%m/%Y")
|
value = datetime.fromisoformat(marche[col]).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
# Listes
|
# Listes
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
from dash import Input, Output, callback, dcc, html, register_page
|
||||||
|
|
||||||
|
from src.figures import DataTable
|
||||||
|
from src.utils import (
|
||||||
|
df_acheteurs,
|
||||||
|
df_titulaires,
|
||||||
|
meta_content,
|
||||||
|
search_org,
|
||||||
|
setup_table_columns,
|
||||||
|
)
|
||||||
|
|
||||||
|
name = "Recherche"
|
||||||
|
|
||||||
|
register_page(
|
||||||
|
__name__,
|
||||||
|
path="/",
|
||||||
|
title=meta_content["title"],
|
||||||
|
name=name,
|
||||||
|
description=meta_content["description"],
|
||||||
|
image_url=meta_content["image_url"],
|
||||||
|
order=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
layout = html.Div(
|
||||||
|
className="container",
|
||||||
|
children=[
|
||||||
|
html.Div(
|
||||||
|
className="tagline",
|
||||||
|
children=html.P(
|
||||||
|
"Exploration et téléchargement des données des marchés publics"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dcc.Input(
|
||||||
|
id="search",
|
||||||
|
type="text",
|
||||||
|
placeholder="Nom d'acheteur/entreprise, SIREN/SIRET, code département",
|
||||||
|
autoFocus=True,
|
||||||
|
),
|
||||||
|
# html.Div(
|
||||||
|
# className="search_options",
|
||||||
|
# children=[dcc.RadioItems(options=["Acheteur(s)"])],
|
||||||
|
# ),
|
||||||
|
html.Div(id="search_results", className="wrapper"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("search_results", "children"),
|
||||||
|
Input("search", "value"),
|
||||||
|
prevent_initial_call=True,
|
||||||
|
)
|
||||||
|
def update_search_results(query):
|
||||||
|
if len(query) >= 1:
|
||||||
|
content = []
|
||||||
|
|
||||||
|
for org_type in ["acheteur", "titulaire"]:
|
||||||
|
if org_type == "acheteur":
|
||||||
|
dff = df_acheteurs
|
||||||
|
elif org_type == "titulaire":
|
||||||
|
dff = df_titulaires
|
||||||
|
else:
|
||||||
|
raise ValueError(f"{org_type} is not supported")
|
||||||
|
|
||||||
|
# Search acheteurs and titulaires using the same function
|
||||||
|
results = search_org(dff, query, org_type=org_type)
|
||||||
|
count = results.height
|
||||||
|
|
||||||
|
# Format output
|
||||||
|
columns, tooltip = setup_table_columns(results, hideable=False)
|
||||||
|
|
||||||
|
org_content = [
|
||||||
|
html.Div(
|
||||||
|
className=f"results_{org_type}",
|
||||||
|
children=[
|
||||||
|
html.H3(f"{org_type.title()}s : {count}"),
|
||||||
|
DataTable(
|
||||||
|
dtid=f"results_{org_type}_datatable",
|
||||||
|
columns=columns,
|
||||||
|
data=results.to_dicts(),
|
||||||
|
page_size=10,
|
||||||
|
sort_action="none",
|
||||||
|
filter_action="none",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
if count > 0
|
||||||
|
else html.P(f"Aucun {org_type} trouvé."),
|
||||||
|
]
|
||||||
|
content.extend(org_content)
|
||||||
|
|
||||||
|
return content
|
||||||
|
return html.P("")
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from dash import dcc, html, register_page
|
from dash import dcc, html, register_page
|
||||||
|
|
||||||
from src.figures import get_barchart_sources, get_map_count_marches
|
from src.figures import get_barchart_sources, get_map_count_marches
|
||||||
from src.utils import lf, meta_content
|
from src.utils import df, meta_content
|
||||||
|
|
||||||
name = "Statistiques"
|
name = "Statistiques"
|
||||||
|
|
||||||
@@ -37,13 +37,13 @@ layout = [
|
|||||||
L'ajout de nouvelles plateformes [est en cours](https://github.com/ColinMaudry/decp-processing/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22source%20de%20donn%C3%A9es%22),
|
L'ajout de nouvelles plateformes [est en cours](https://github.com/ColinMaudry/decp-processing/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22source%20de%20donn%C3%A9es%22),
|
||||||
toutes les [contributions](/a-propos#contribuer) sont les bienvenues pour atteindre l'exhaustivité.
|
toutes les [contributions](/a-propos#contribuer) sont les bienvenues pour atteindre l'exhaustivité.
|
||||||
"""),
|
"""),
|
||||||
dcc.Graph(figure=get_map_count_marches(lf)),
|
dcc.Graph(figure=get_map_count_marches(df)),
|
||||||
dcc.Graph(
|
dcc.Graph(
|
||||||
figure=get_barchart_sources(lf, "dateNotification")
|
figure=get_barchart_sources(df, "dateNotification")
|
||||||
),
|
),
|
||||||
dcc.Graph(
|
dcc.Graph(
|
||||||
figure=get_barchart_sources(
|
figure=get_barchart_sources(
|
||||||
lf, "datePublicationDonnees"
|
df, "datePublicationDonnees"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import urllib.parse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import Input, Output, State, callback, dash_table, dcc, html, register_page
|
from dash import Input, Output, State, callback, dcc, html, no_update, register_page
|
||||||
|
|
||||||
|
from src.figures import DataTable
|
||||||
from src.utils import (
|
from src.utils import (
|
||||||
add_links,
|
df,
|
||||||
add_resource_link,
|
|
||||||
filter_table_data,
|
filter_table_data,
|
||||||
format_montant,
|
get_default_hidden_columns,
|
||||||
format_number,
|
invert_columns,
|
||||||
lf,
|
|
||||||
meta_content,
|
meta_content,
|
||||||
setup_table_columns,
|
schema,
|
||||||
sort_table_data,
|
sort_table_data,
|
||||||
)
|
)
|
||||||
|
from utils import prepare_table_data
|
||||||
|
|
||||||
update_date = os.path.getmtime(os.getenv("DATA_FILE_PARQUET_PATH"))
|
update_date = os.path.getmtime(os.getenv("DATA_FILE_PARQUET_PATH"))
|
||||||
update_date = datetime.fromtimestamp(update_date).strftime("%d/%m/%Y")
|
update_date = datetime.fromtimestamp(update_date).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
schema = lf.collect_schema()
|
|
||||||
|
|
||||||
name = "Tableau"
|
name = "Tableau"
|
||||||
register_page(
|
register_page(
|
||||||
__name__,
|
__name__,
|
||||||
path="/",
|
path="/tableau",
|
||||||
title=meta_content["title"],
|
title=meta_content["title"],
|
||||||
name=name,
|
name=name,
|
||||||
description=meta_content["description"],
|
description=meta_content["description"],
|
||||||
@@ -34,60 +35,28 @@ register_page(
|
|||||||
|
|
||||||
datatable = html.Div(
|
datatable = html.Div(
|
||||||
className="marches_table",
|
className="marches_table",
|
||||||
children=dash_table.DataTable(
|
children=DataTable(
|
||||||
cell_selectable=False,
|
dtid="table",
|
||||||
id="table",
|
|
||||||
page_size=20,
|
page_size=20,
|
||||||
page_current=0,
|
|
||||||
page_action="custom",
|
page_action="custom",
|
||||||
filter_action="custom",
|
filter_action="custom",
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
|
||||||
sort_action="custom",
|
sort_action="custom",
|
||||||
sort_mode="multi",
|
hidden_columns=get_default_hidden_columns(None),
|
||||||
sort_by=[],
|
columns=[{"id": col, "name": col} for col in df.columns],
|
||||||
row_deletable=False,
|
|
||||||
style_cell_conditional=[
|
|
||||||
{
|
|
||||||
"if": {"column_id": "objet"},
|
|
||||||
"minWidth": "350px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "14px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"if": {"column_id": "acheteur_nom"},
|
|
||||||
"minWidth": "250px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "14px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"if": {"column_id": "titulaire_nom"},
|
|
||||||
"minWidth": "250px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "14px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
data_timestamp=0,
|
|
||||||
markdown_options={"html": True},
|
|
||||||
tooltip_duration=8000,
|
|
||||||
tooltip_delay=350,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
|
dcc.Location(id="url", refresh=False),
|
||||||
html.Div(
|
html.Div(
|
||||||
html.Details(
|
html.Details(
|
||||||
children=[
|
children=[
|
||||||
html.Summary(
|
html.Summary(
|
||||||
html.H3("Mode d'emploi", style={"text-decoration": "underline"}),
|
html.H3("Mode d'emploi", style={"textDecoration": "underline"}),
|
||||||
),
|
),
|
||||||
dcc.Markdown(
|
dcc.Markdown(
|
||||||
"""
|
dangerously_allow_html=True,
|
||||||
|
children="""
|
||||||
##### Définition des colonnes
|
##### Définition des colonnes
|
||||||
|
|
||||||
Pour voir la définition d'une colonne, passez votre souris sur son en-tête.
|
Pour voir la définition d'une colonne, passez votre souris sur son en-tête.
|
||||||
@@ -97,10 +66,10 @@ layout = [
|
|||||||
Vous pouvez appliquer un filtre pour chaque colonne en entrant du texte sous le nom de la colonne, puis en tapant sur `Entrée`.
|
Vous pouvez appliquer un filtre pour chaque colonne en entrant du texte sous le nom de la colonne, puis en tapant sur `Entrée`.
|
||||||
|
|
||||||
- Champs textuels : la recherche est insensible à la casse (majuscules/minuscules) et retourne les valeurs qui contiennent
|
- Champs textuels : la recherche est insensible à la casse (majuscules/minuscules) et retourne les valeurs qui contiennent
|
||||||
le texte recherché. Exemple : `rennes` retourne "RENNES METROPOLE".
|
le texte recherché. Exemple : `rennes` retourne "RENNES METROPOLE". Lorsque vous ouvrez une URL de vue, le format équivalent `icontains rennes` est utilisé.
|
||||||
- Champs numériques : vous pouvez soit taper un nombre pour trouver les valeurs égales, soit le précéder de **>** ou **<** pour filtrer les valeurs supérieures ou inférieures. Exemple pour les offres reçues : `> 4` retourne les marchés ayant reçu plus de 4 offres.
|
- Champs numériques : vous pouvez soit taper un nombre pour trouver les valeurs égales, soit le précéder de **>** ou **<** pour filtrer les valeurs supérieures ou inférieures. Exemple pour les offres reçues : `> 4` retourne les marchés ayant reçu plus de 4 offres.
|
||||||
- Champs date : vous pouvez également utiliser **>** ou **<**. Exemples : `< 2024-01-31` pour "avant le 31 janvier 2024",
|
- Champs date : vous pouvez également utiliser **>** ou **<**. Exemples : `< 2024-01-31` pour "avant le 31 janvier 2024",
|
||||||
`2024` pour "en 2024", `> 2022` pour "à partir de 2022"
|
`2024` pour "en 2024", `> 2022` pour "à partir de 2022". Lorsque vous ouvrez une URL de vue, le format équivalent `i<` ou `i>` est utilisé.
|
||||||
|
|
||||||
Vous pouvez filtrer plusieurs colonnes à la fois. Vos filtres sont remis à zéro quand vous rafraîchissez la page.
|
Vous pouvez filtrer plusieurs colonnes à la fois. Vos filtres sont remis à zéro quand vous rafraîchissez la page.
|
||||||
|
|
||||||
@@ -108,6 +77,12 @@ layout = [
|
|||||||
|
|
||||||
Pour trier une colonne, utilisez les flèches grises à côté des noms de colonnes. Chaque clic change le tri dans cet ordre : tri ascendant, tri descendant, pas de tri.
|
Pour trier une colonne, utilisez les flèches grises à côté des noms de colonnes. Chaque clic change le tri dans cet ordre : tri ascendant, tri descendant, pas de tri.
|
||||||
|
|
||||||
|
##### Partager une vue
|
||||||
|
|
||||||
|
Une vue est un ensemble de filtres, de tris et de choix de colonnes que vous avez appliqué. Vous pouvez copier une adresse Web qui reproduit la vue courante à l'identique en cliquant sur l'icône <img src="/assets/copy.svg" alt="drawing" width="20"/>. En la collant dans la barre d'adresse d'un navigateur, vous ouvrez la vue Tableau avec les mêmes paramètres.
|
||||||
|
|
||||||
|
Pratique pour partager une vue avec un·e collègue, sur les réseaux sociaux, ou la sauvegarder pour plus tard.
|
||||||
|
|
||||||
##### Télécharger le résultat
|
##### Télécharger le résultat
|
||||||
|
|
||||||
Vous pouvez télécharger le résultat de vos filtres et tris, pour les colonnes affichées, en cliquant sur **Télécharger au format Excel**.
|
Vous pouvez télécharger le résultat de vos filtres et tris, pour les colonnes affichées, en cliquant sur **Télécharger au format Excel**.
|
||||||
@@ -117,7 +92,7 @@ layout = [
|
|||||||
Les liens dans les colonnes Identifiant unique, Acheteur et Titulaire vous permettent de consulter une vue qui leur est dédiée
|
Les liens dans les colonnes Identifiant unique, Acheteur et Titulaire vous permettent de consulter une vue qui leur est dédiée
|
||||||
(informations, marchés attribués/remportés, etc.)
|
(informations, marchés attribués/remportés, etc.)
|
||||||
|
|
||||||
"""
|
""",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
id="instructions",
|
id="instructions",
|
||||||
@@ -138,6 +113,8 @@ layout = [
|
|||||||
html.Div(
|
html.Div(
|
||||||
[
|
[
|
||||||
html.P("lignes", id="nb_rows"),
|
html.P("lignes", id="nb_rows"),
|
||||||
|
html.Div(id="copy-container"),
|
||||||
|
dcc.Input(id="share-url", readOnly=True, style={"display": "none"}),
|
||||||
html.Button(
|
html.Button(
|
||||||
"Téléchargement désactivé au-delà de 65 000 lignes",
|
"Téléchargement désactivé au-delà de 65 000 lignes",
|
||||||
id="btn-download-data",
|
id="btn-download-data",
|
||||||
@@ -171,62 +148,12 @@ layout = [
|
|||||||
State("table", "data_timestamp"),
|
State("table", "data_timestamp"),
|
||||||
)
|
)
|
||||||
def update_table(page_current, page_size, filter_query, sort_by, data_timestamp):
|
def update_table(page_current, page_size, filter_query, sort_by, data_timestamp):
|
||||||
print(" + + + + + + + + + + + + + + + + + + ")
|
# if ctx.triggered_id != "url":
|
||||||
|
# search_params = None
|
||||||
# Application des filtres
|
# else:
|
||||||
lff: pl.LazyFrame = lf # start from the original data
|
# search_params = urllib.parse.parse_qs(search_params.lstrip("?"))
|
||||||
if filter_query:
|
return prepare_table_data(
|
||||||
lff = filter_table_data(lff, filter_query)
|
None, data_timestamp, filter_query, page_current, page_size, sort_by
|
||||||
|
|
||||||
if len(sort_by) > 0:
|
|
||||||
lff = sort_table_data(lff, sort_by)
|
|
||||||
|
|
||||||
# Remplace les strings null par "", mais pas les numeric null
|
|
||||||
lff = lff.fill_null("")
|
|
||||||
|
|
||||||
# Matérialisation des filtres
|
|
||||||
dff: pl.DataFrame = lff.collect()
|
|
||||||
|
|
||||||
height = dff.height
|
|
||||||
|
|
||||||
nb_rows = f"{format_number(height)} lignes"
|
|
||||||
|
|
||||||
# Pagination des données
|
|
||||||
start_row = page_current * page_size
|
|
||||||
# end_row = (page_current + 1) * page_size
|
|
||||||
dff = dff.slice(start_row, page_size)
|
|
||||||
|
|
||||||
# Ajout des liens vers l'annuaire des entreprises
|
|
||||||
dff = add_links(dff)
|
|
||||||
|
|
||||||
# Ajout des liens vers les fichiers Open Data
|
|
||||||
dff = add_resource_link(dff)
|
|
||||||
|
|
||||||
# Formatage des montants
|
|
||||||
dff = format_montant(dff)
|
|
||||||
|
|
||||||
columns, tooltip = setup_table_columns(dff)
|
|
||||||
|
|
||||||
dicts = dff.to_dicts()
|
|
||||||
|
|
||||||
if height > 65000:
|
|
||||||
download_disabled = True
|
|
||||||
download_text = "Téléchargement désactivé au-delà de 65 000 lignes"
|
|
||||||
download_title = "Excel ne supporte pas d'avoir plus de 65 000 URLs dans une même feuille de calcul. Contactez-moi pour me présenter votre besoin en téléchargement afin que je puisse adapter la solution."
|
|
||||||
else:
|
|
||||||
download_disabled = False
|
|
||||||
download_text = "Télécharger au format Excel"
|
|
||||||
download_title = ""
|
|
||||||
|
|
||||||
return (
|
|
||||||
dicts,
|
|
||||||
columns,
|
|
||||||
tooltip,
|
|
||||||
data_timestamp + 1,
|
|
||||||
nb_rows,
|
|
||||||
download_disabled,
|
|
||||||
download_text,
|
|
||||||
download_title,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -239,7 +166,7 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
prevent_initial_call=True,
|
prevent_initial_call=True,
|
||||||
)
|
)
|
||||||
def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None):
|
def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None):
|
||||||
lff: pl.LazyFrame = lf # start from the original data
|
lff: pl.LazyFrame = df.lazy() # start from the original data
|
||||||
|
|
||||||
# Les colonnes masquées sont supprimées
|
# Les colonnes masquées sont supprimées
|
||||||
if hidden_columns:
|
if hidden_columns:
|
||||||
@@ -256,3 +183,99 @@ def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None):
|
|||||||
|
|
||||||
date = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
date = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
return dcc.send_bytes(to_bytes, filename=f"decp_{date}.xlsx")
|
return dcc.send_bytes(to_bytes, filename=f"decp_{date}.xlsx")
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("table", "filter_query"),
|
||||||
|
Output("table", "sort_by"),
|
||||||
|
Output("table", "hidden_columns"),
|
||||||
|
Output("url", "search", allow_duplicate=True),
|
||||||
|
Input("url", "search"),
|
||||||
|
prevent_initial_call=True,
|
||||||
|
)
|
||||||
|
def restore_view_from_url(search):
|
||||||
|
if not search:
|
||||||
|
return no_update, no_update, no_update, no_update
|
||||||
|
|
||||||
|
params = urllib.parse.parse_qs(search.lstrip("?"))
|
||||||
|
print("params", params)
|
||||||
|
|
||||||
|
filter_query = no_update
|
||||||
|
sort_by = no_update
|
||||||
|
hidden_columns = no_update
|
||||||
|
|
||||||
|
if "filtres" in params:
|
||||||
|
filter_query = params["filtres"][0]
|
||||||
|
|
||||||
|
if "tris" in params:
|
||||||
|
try:
|
||||||
|
sort_by = json.loads(params["tris"][0])
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if "colonnes" in params:
|
||||||
|
columns = params["colonnes"][0].split(",")
|
||||||
|
verified_columns = [column for column in columns if column in schema.names()]
|
||||||
|
hidden_columns = invert_columns(verified_columns)
|
||||||
|
|
||||||
|
return filter_query, sort_by, hidden_columns, ""
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("share-url", "value"),
|
||||||
|
Output("copy-container", "children"),
|
||||||
|
Input("table", "filter_query"),
|
||||||
|
Input("table", "sort_by"),
|
||||||
|
Input("table", "hidden_columns"),
|
||||||
|
State("url", "href"),
|
||||||
|
)
|
||||||
|
def sync_url_and_reset_button(filter_query, sort_by, hidden_columns, href):
|
||||||
|
if not href:
|
||||||
|
return no_update, no_update
|
||||||
|
|
||||||
|
# Extract base URL (remove existing query params)
|
||||||
|
base_url = href.split("?")[0]
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
if filter_query:
|
||||||
|
params["filtres"] = filter_query
|
||||||
|
|
||||||
|
if sort_by:
|
||||||
|
params["tris"] = json.dumps(sort_by)
|
||||||
|
|
||||||
|
if hidden_columns:
|
||||||
|
columns = invert_columns(hidden_columns)
|
||||||
|
columns = ",".join(columns)
|
||||||
|
params["colonnes"] = columns
|
||||||
|
|
||||||
|
query_string = urllib.parse.urlencode(params)
|
||||||
|
full_url = f"{base_url}?{query_string}" if query_string else base_url
|
||||||
|
|
||||||
|
copy_button = dcc.Clipboard(
|
||||||
|
id="btn-copy-url",
|
||||||
|
target_id="share-url",
|
||||||
|
title="Copier l'URL de cette vue",
|
||||||
|
style={
|
||||||
|
"display": "inline-block",
|
||||||
|
"fontSize": 20,
|
||||||
|
"verticalAlign": "top",
|
||||||
|
"cursor": "pointer",
|
||||||
|
},
|
||||||
|
className="fa fa-link",
|
||||||
|
)
|
||||||
|
|
||||||
|
return full_url, copy_button
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("copy-container", "children", allow_duplicate=True),
|
||||||
|
Input("btn-copy-url", "n_clicks", allow_optional=True),
|
||||||
|
prevent_initial_call=True,
|
||||||
|
)
|
||||||
|
def show_confirmation(n_clicks):
|
||||||
|
if n_clicks:
|
||||||
|
return html.Span(
|
||||||
|
"Adresse de la vue copiée",
|
||||||
|
style={"color": "green", "fontWeight": "bold", "marginLeft": "10px"},
|
||||||
|
)
|
||||||
|
return no_update
|
||||||
+143
-101
@@ -1,18 +1,21 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import Input, Output, State, callback, dash_table, dcc, html, register_page
|
from dash import Input, Output, State, callback, dcc, html, register_page
|
||||||
|
|
||||||
from src.figures import point_on_map
|
from src.callbacks import get_top_org_table
|
||||||
|
from src.figures import DataTable, point_on_map
|
||||||
from src.utils import (
|
from src.utils import (
|
||||||
add_links_in_dict,
|
df,
|
||||||
format_montant,
|
filter_table_data,
|
||||||
format_number,
|
format_number,
|
||||||
get_annuaire_data,
|
get_annuaire_data,
|
||||||
|
get_button_properties,
|
||||||
|
get_default_hidden_columns,
|
||||||
get_departement_region,
|
get_departement_region,
|
||||||
lf,
|
|
||||||
meta_content,
|
meta_content,
|
||||||
setup_table_columns,
|
prepare_table_data,
|
||||||
|
sort_table_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
@@ -25,13 +28,22 @@ register_page(
|
|||||||
order=5,
|
order=5,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 21690123100011
|
datatable = html.Div(
|
||||||
|
className="marches_table",
|
||||||
|
children=DataTable(
|
||||||
|
dtid="titulaire_datatable",
|
||||||
|
page_action="custom",
|
||||||
|
filter_action="custom",
|
||||||
|
sort_action="custom",
|
||||||
|
page_size=10,
|
||||||
|
hidden_columns=get_default_hidden_columns(page="titulaire"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
dcc.Store(id="titulaire_data", storage_type="memory"),
|
dcc.Store(id="titulaire_data", storage_type="memory"),
|
||||||
dcc.Location(id="url", refresh="callback-nav"),
|
dcc.Location(id="url", refresh="callback-nav"),
|
||||||
html.Div(
|
html.Div(
|
||||||
className="container",
|
|
||||||
children=[
|
children=[
|
||||||
html.Div(
|
html.Div(
|
||||||
className="wrapper",
|
className="wrapper",
|
||||||
@@ -85,17 +97,43 @@ layout = [
|
|||||||
html.P(id="titulaire_acheteurs_differents"),
|
html.P(id="titulaire_acheteurs_differents"),
|
||||||
html.Button(
|
html.Button(
|
||||||
"Téléchargement au format Excel",
|
"Téléchargement au format Excel",
|
||||||
id="btn-download-titulaire-data",
|
id="btn-download-data-titulaire",
|
||||||
),
|
),
|
||||||
dcc.Download(id="download-titulaire-data"),
|
dcc.Download(id="download-data-titulaire"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
html.Div(className="org_map", id="titulaire_map"),
|
html.Div(className="org_map", id="titulaire_map"),
|
||||||
|
html.Div(
|
||||||
|
className="org_top",
|
||||||
|
children=[
|
||||||
|
html.H3("Top acheteurs"),
|
||||||
|
html.Div(className="marches_table", id="top10_acheteurs"),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
# récupérer les données de l'acheteur sur l'api annuaire
|
# récupérer les données de l'acheteur sur l'api annuaire
|
||||||
html.H3("Derniers marchés publics remportés"),
|
html.H3("Derniers marchés publics remportés"),
|
||||||
html.Div(id="titulaire_last_marches", children=""),
|
dcc.Loading(
|
||||||
|
overlay_style={"visibility": "visible", "filter": "blur(2px)"},
|
||||||
|
id="loading-home",
|
||||||
|
type="default",
|
||||||
|
children=[
|
||||||
|
html.Div(
|
||||||
|
[
|
||||||
|
html.P("lignes", id="titulaire_nb_rows"),
|
||||||
|
html.Button(
|
||||||
|
"Téléchargement désactivé au-delà de 65 000 lignes",
|
||||||
|
id="btn-download-filtered-data-titulaire",
|
||||||
|
disabled=True,
|
||||||
|
),
|
||||||
|
dcc.Download(id="titulaire-download-filtered-data"),
|
||||||
|
],
|
||||||
|
className="table-menu",
|
||||||
|
),
|
||||||
|
datatable,
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -148,125 +186,93 @@ def update_titulaire_infos(url):
|
|||||||
Input(component_id="titulaire_data", component_property="data"),
|
Input(component_id="titulaire_data", component_property="data"),
|
||||||
)
|
)
|
||||||
def update_titulaire_stats(data):
|
def update_titulaire_stats(data):
|
||||||
df = pl.DataFrame(data)
|
dff = pl.DataFrame(data, strict=False, infer_schema_length=5000)
|
||||||
if df.height == 0:
|
if dff.height == 0:
|
||||||
df = pl.DataFrame(schema=lf.collect_schema())
|
nb_marches = 0
|
||||||
df_marches = df.unique("uid")
|
nb_acheteurs = 0
|
||||||
|
else:
|
||||||
|
df_marches = dff.unique("uid")
|
||||||
nb_marches = format_number(df_marches.height)
|
nb_marches = format_number(df_marches.height)
|
||||||
# somme_marches = format_number(int(df_marches.select(pl.sum("montant")).item()))
|
nb_acheteurs = dff.unique("acheteur_id").height
|
||||||
marches_remportes = [html.Strong(nb_marches), " marchés et accord-cadres remportés"]
|
|
||||||
# + ", pour un total de ", html.Strong(somme_marches + " €")]
|
|
||||||
del df_marches
|
|
||||||
|
|
||||||
nb_acheteurs = df.unique("acheteur_id").height
|
texte_marches_remportes = [
|
||||||
nb_acheteurs = [
|
html.Strong(nb_marches),
|
||||||
html.Strong(format_number(nb_acheteurs)),
|
" marchés et accord-cadres remportés",
|
||||||
" titulaires (SIRET) différents",
|
|
||||||
]
|
]
|
||||||
del df
|
# + ", pour un total de ", html.Strong(somme_marches + " €")]
|
||||||
|
|
||||||
return marches_remportes, nb_acheteurs
|
texte_nb_acheteurs = [
|
||||||
|
html.Strong(format_number(nb_acheteurs)),
|
||||||
|
" acheteurs (SIRET) différents",
|
||||||
|
]
|
||||||
|
|
||||||
|
return texte_marches_remportes, texte_nb_acheteurs
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output(component_id="titulaire_data", component_property="data"),
|
Output(component_id="titulaire_data", component_property="data"),
|
||||||
|
Output("btn-download-data-titulaire", "disabled"),
|
||||||
|
Output("btn-download-data-titulaire", "children"),
|
||||||
|
Output("btn-download-data-titulaire", "title"),
|
||||||
Input(component_id="url", component_property="pathname"),
|
Input(component_id="url", component_property="pathname"),
|
||||||
Input(component_id="titulaire_year", component_property="value"),
|
Input(component_id="titulaire_year", component_property="value"),
|
||||||
)
|
)
|
||||||
def get_titulaire_marches_data(url, titulaire_year: str) -> pl.LazyFrame:
|
def get_titulaire_marches_data(url, titulaire_year: str) -> tuple:
|
||||||
titulaire_siret = url.split("/")[-1]
|
titulaire_siret = url.split("/")[-1]
|
||||||
lff = lf.filter(
|
lff = df.lazy()
|
||||||
|
lff = lff.filter(
|
||||||
(pl.col("titulaire_id") == titulaire_siret)
|
(pl.col("titulaire_id") == titulaire_siret)
|
||||||
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
||||||
)
|
)
|
||||||
lff = lff.fill_null("")
|
|
||||||
lff = lff.select(
|
|
||||||
"id",
|
|
||||||
"uid",
|
|
||||||
"objet",
|
|
||||||
"dateNotification",
|
|
||||||
"acheteur_id",
|
|
||||||
"acheteur_nom",
|
|
||||||
"montant",
|
|
||||||
"codeCPV",
|
|
||||||
"dureeMois",
|
|
||||||
)
|
|
||||||
if titulaire_year and titulaire_year != "Toutes":
|
if titulaire_year and titulaire_year != "Toutes":
|
||||||
lff = lff.filter(
|
lff = lff.filter(
|
||||||
pl.col("dateNotification").cast(pl.String).str.starts_with(titulaire_year)
|
pl.col("dateNotification").cast(pl.String).str.starts_with(titulaire_year)
|
||||||
)
|
)
|
||||||
lff = lff.sort(["dateNotification", "uid"], descending=True, nulls_last=True)
|
lff = lff.sort(["dateNotification", "uid"], descending=True, nulls_last=True)
|
||||||
|
lff = lff.fill_null("")
|
||||||
|
|
||||||
data = lff.collect(engine="streaming").to_dicts()
|
dff: pl.DataFrame = lff.collect(engine="streaming")
|
||||||
return data
|
download_disabled, download_text, download_title = get_button_properties(dff.height)
|
||||||
|
|
||||||
|
data = dff.to_dicts()
|
||||||
|
return data, download_disabled, download_text, download_title
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output(component_id="titulaire_last_marches", component_property="children"),
|
Output("titulaire_datatable", "data"),
|
||||||
|
Output("titulaire_datatable", "columns"),
|
||||||
|
Output("titulaire_datatable", "tooltip_header"),
|
||||||
|
Output("titulaire_datatable", "data_timestamp"),
|
||||||
|
Output("titulaire_nb_rows", "children"),
|
||||||
|
Output("btn-download-filtered-data-titulaire", "disabled"),
|
||||||
|
Output("btn-download-filtered-data-titulaire", "children"),
|
||||||
|
Output("btn-download-filtered-data-titulaire", "title"),
|
||||||
|
Input("titulaire_data", "data"),
|
||||||
|
Input("titulaire_datatable", "page_current"),
|
||||||
|
Input("titulaire_datatable", "page_size"),
|
||||||
|
Input("titulaire_datatable", "filter_query"),
|
||||||
|
Input("titulaire_datatable", "sort_by"),
|
||||||
|
State("titulaire_datatable", "data_timestamp"),
|
||||||
|
)
|
||||||
|
def get_last_marches_data(
|
||||||
|
data, page_current, page_size, filter_query, sort_by, data_timestamp
|
||||||
|
) -> list[dict]:
|
||||||
|
return prepare_table_data(
|
||||||
|
data, data_timestamp, filter_query, page_current, page_size, sort_by
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output(component_id="top10_acheteurs", component_property="children"),
|
||||||
Input(component_id="titulaire_data", component_property="data"),
|
Input(component_id="titulaire_data", component_property="data"),
|
||||||
)
|
)
|
||||||
def get_last_marches_table(data) -> html.Div:
|
def get_top_acheteurs(data):
|
||||||
columns = [
|
return get_top_org_table(data, "acheteur")
|
||||||
"uid",
|
|
||||||
"objet",
|
|
||||||
"dateNotification",
|
|
||||||
"acheteur_nom",
|
|
||||||
"montant",
|
|
||||||
"codeCPV",
|
|
||||||
"dureeMois",
|
|
||||||
]
|
|
||||||
|
|
||||||
dff = pl.DataFrame(data)
|
|
||||||
dff = format_montant(dff)
|
|
||||||
columns, tooltip = setup_table_columns(
|
|
||||||
dff, hideable=False, exclude=["acheteur_id", "id"]
|
|
||||||
)
|
|
||||||
data = dff.to_dicts()
|
|
||||||
# Idéalement on utiliserait add_org_links(), mais le résultat attendu
|
|
||||||
# est différent de home.py (Tableau)
|
|
||||||
data = add_links_in_dict(data, "acheteur")
|
|
||||||
|
|
||||||
table = html.Div(
|
|
||||||
className="marches_table",
|
|
||||||
id="titulaire_datatable",
|
|
||||||
children=dash_table.DataTable(
|
|
||||||
data=data,
|
|
||||||
markdown_options={"html": True},
|
|
||||||
page_action="native",
|
|
||||||
filter_action="native",
|
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
|
||||||
columns=columns,
|
|
||||||
tooltip_header=tooltip,
|
|
||||||
tooltip_duration=8000,
|
|
||||||
tooltip_delay=350,
|
|
||||||
cell_selectable=False,
|
|
||||||
page_size=10,
|
|
||||||
style_cell_conditional=[
|
|
||||||
{
|
|
||||||
"if": {"column_id": "objet"},
|
|
||||||
"minWidth": "300px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "14px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"if": {"column_id": "acheteur_nom"},
|
|
||||||
"maxWidth": "400px",
|
|
||||||
"textAlign": "left",
|
|
||||||
"overflow": "hidden",
|
|
||||||
"lineHeight": "18px",
|
|
||||||
"whiteSpace": "normal",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return table
|
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output("download-titulaire-data", "data"),
|
Output("download-data-titulaire", "data"),
|
||||||
Input("btn-download-titulaire-data", "n_clicks"),
|
Input("btn-download-data-titulaire", "n_clicks"),
|
||||||
State(component_id="titulaire_data", component_property="data"),
|
State(component_id="titulaire_data", component_property="data"),
|
||||||
State(component_id="titulaire_nom", component_property="children"),
|
State(component_id="titulaire_nom", component_property="children"),
|
||||||
State(component_id="titulaire_year", component_property="value"),
|
State(component_id="titulaire_year", component_property="value"),
|
||||||
@@ -287,3 +293,39 @@ def download_titulaire_data(
|
|||||||
|
|
||||||
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
return dcc.send_bytes(to_bytes, filename=f"decp_{titulaire_nom}_{date}.xlsx")
|
return dcc.send_bytes(to_bytes, filename=f"decp_{titulaire_nom}_{date}.xlsx")
|
||||||
|
|
||||||
|
|
||||||
|
@callback(
|
||||||
|
Output("titulaire-download-filtered-data", "data"),
|
||||||
|
State("titulaire_data", "data"),
|
||||||
|
Input("btn-download-filtered-data-titulaire", "n_clicks"),
|
||||||
|
State("titulaire_nom", "children"),
|
||||||
|
State("titulaire_datatable", "filter_query"),
|
||||||
|
State("titulaire_datatable", "sort_by"),
|
||||||
|
State("titulaire_datatable", "hidden_columns"),
|
||||||
|
prevent_initial_call=True,
|
||||||
|
)
|
||||||
|
def download_filtered_titulaire_data(
|
||||||
|
data, n_clicks, titulaire_nom, filter_query, sort_by, hidden_columns: list = None
|
||||||
|
):
|
||||||
|
lff: pl.LazyFrame = pl.LazyFrame(
|
||||||
|
data
|
||||||
|
) # start from the full titulaire data, not from paginated table data
|
||||||
|
|
||||||
|
# Les colonnes masquées sont supprimées
|
||||||
|
if hidden_columns:
|
||||||
|
lff = lff.drop(hidden_columns)
|
||||||
|
|
||||||
|
if filter_query:
|
||||||
|
lff = filter_table_data(lff, filter_query)
|
||||||
|
|
||||||
|
if len(sort_by) > 0:
|
||||||
|
lff = sort_table_data(lff, sort_by)
|
||||||
|
|
||||||
|
def to_bytes(buffer):
|
||||||
|
lff.collect(engine="streaming").write_excel(buffer, worksheet="DECP")
|
||||||
|
|
||||||
|
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
|
return dcc.send_bytes(
|
||||||
|
to_bytes, filename=f"decp_filtrées_{titulaire_nom}_{date}.xlsx"
|
||||||
|
)
|
||||||
|
|||||||
+434
-61
@@ -1,22 +1,18 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from time import sleep
|
import uuid
|
||||||
|
from time import localtime, sleep
|
||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
import polars.selectors as cs
|
import polars.selectors as cs
|
||||||
from httpx import get
|
from httpx import get, post
|
||||||
from polars.exceptions import ComputeError
|
from polars.exceptions import ComputeError
|
||||||
|
from unidecode import unidecode
|
||||||
operators = [
|
|
||||||
["s<", "<"],
|
|
||||||
["s>", ">"],
|
|
||||||
["i<", "<"],
|
|
||||||
["i>", ">"],
|
|
||||||
["icontains", "contains"],
|
|
||||||
]
|
|
||||||
|
|
||||||
logger = logging.getLogger("decp.info")
|
logger = logging.getLogger("decp.info")
|
||||||
|
logging.getLogger("httpx").setLevel("WARNING")
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s %(levelname)-8s %(message)s",
|
format="%(asctime)s %(levelname)-8s %(message)s",
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@@ -25,6 +21,14 @@ logging.basicConfig(
|
|||||||
|
|
||||||
|
|
||||||
def split_filter_part(filter_part):
|
def split_filter_part(filter_part):
|
||||||
|
operators = [
|
||||||
|
["s<", "<"],
|
||||||
|
["s>", ">"],
|
||||||
|
["i<", "<"],
|
||||||
|
["i>", ">"],
|
||||||
|
["icontains", "contains"],
|
||||||
|
# [" ", "contains"]
|
||||||
|
]
|
||||||
print("filter part", filter_part)
|
print("filter part", filter_part)
|
||||||
for operator_group in operators:
|
for operator_group in operators:
|
||||||
if operator_group[0] in filter_part:
|
if operator_group[0] in filter_part:
|
||||||
@@ -43,46 +47,64 @@ def add_resource_link(dff: pl.DataFrame) -> pl.DataFrame:
|
|||||||
dff = dff.with_columns(
|
dff = dff.with_columns(
|
||||||
(
|
(
|
||||||
'<a href="' + pl.col("sourceFile") + '">' + pl.col("sourceDataset") + "</a>"
|
'<a href="' + pl.col("sourceFile") + '">' + pl.col("sourceDataset") + "</a>"
|
||||||
).alias("source")
|
).alias("sourceDataset")
|
||||||
)
|
)
|
||||||
dff = dff.drop(["sourceFile", "sourceDataset"])
|
dff = dff.drop(["sourceFile"])
|
||||||
return dff
|
return dff
|
||||||
|
|
||||||
|
|
||||||
def add_links(dff: pl.DataFrame):
|
def add_links(dff: pl.DataFrame, target: str = "_blank"):
|
||||||
|
for col in ["uid", "acheteur_nom", "titulaire_nom", "acheteur_id", "titulaire_id"]:
|
||||||
|
if col in dff.columns:
|
||||||
|
if col.startswith("titulaire_"):
|
||||||
dff = dff.with_columns(
|
dff = dff.with_columns(
|
||||||
pl.when(pl.col("titulaire_typeIdentifiant") == "SIRET")
|
pl.when(
|
||||||
|
pl.Expr.or_(
|
||||||
|
pl.col("titulaire_typeIdentifiant").is_null(),
|
||||||
|
pl.col("titulaire_typeIdentifiant") == "SIRET",
|
||||||
|
)
|
||||||
|
)
|
||||||
.then(
|
.then(
|
||||||
'<a href = "/titulaires/'
|
'<a href = "/titulaires/'
|
||||||
+ pl.col("titulaire_id")
|
+ pl.col("titulaire_id")
|
||||||
+ '">'
|
+ f'" target="{target}">'
|
||||||
+ pl.col("titulaire_id")
|
+ pl.col(col)
|
||||||
+ "</a>"
|
+ "</a>"
|
||||||
)
|
)
|
||||||
.otherwise(pl.col("titulaire_id"))
|
.otherwise(pl.col(col))
|
||||||
.alias("titulaire_id")
|
.alias(col)
|
||||||
)
|
)
|
||||||
|
if col.startswith("acheteur_"):
|
||||||
for column, path in [("acheteur_id", "acheteurs"), ("uid", "marches")]:
|
|
||||||
dff = dff.with_columns(
|
dff = dff.with_columns(
|
||||||
(
|
(
|
||||||
f'<a href = "/{path}/'
|
'<a href = "/acheteurs/'
|
||||||
+ pl.col(column)
|
+ pl.col("acheteur_id")
|
||||||
+ '" target="_blank">'
|
+ f'" target="{target}">'
|
||||||
+ pl.col(column)
|
+ pl.col(col)
|
||||||
+ "</a>"
|
+ "</a>"
|
||||||
).alias(column)
|
).alias(col)
|
||||||
|
)
|
||||||
|
if col == "uid":
|
||||||
|
dff = dff.with_columns(
|
||||||
|
(
|
||||||
|
'<a href = "/marches/'
|
||||||
|
+ pl.col("uid")
|
||||||
|
+ f'" target="{target}">'
|
||||||
|
+ pl.col("uid")
|
||||||
|
+ "</a>"
|
||||||
|
).alias("uid")
|
||||||
)
|
)
|
||||||
return dff
|
return dff
|
||||||
|
|
||||||
|
|
||||||
def add_links_in_dict(data: list, org_type: str) -> list:
|
def add_links_in_dict(data: list[dict], org_type: str) -> list:
|
||||||
new_data = []
|
new_data = []
|
||||||
for marche in data:
|
for marche in data:
|
||||||
org_id = marche[org_type + "_id"]
|
org_id = marche[org_type + "_id"]
|
||||||
marche[org_type + "_nom"] = (
|
marche[org_type + "_nom"] = (
|
||||||
f'<a href="/{org_type}s/{org_id}">{marche[org_type + "_nom"]}</a>'
|
f'<a href="/{org_type}s/{org_id}">{marche[org_type + "_nom"]}</a>'
|
||||||
)
|
)
|
||||||
|
if marche.get("uid"):
|
||||||
marche["id"] = f'<a href="/marches/{marche["uid"]}">{marche["id"]}</a>'
|
marche["id"] = f'<a href="/marches/{marche["uid"]}">{marche["id"]}</a>'
|
||||||
marche["uid"] = f'<a href="/marches/{marche["uid"]}">{marche["uid"]}</a>'
|
marche["uid"] = f'<a href="/marches/{marche["uid"]}">{marche["uid"]}</a>'
|
||||||
new_data.append(marche)
|
new_data.append(marche)
|
||||||
@@ -123,10 +145,11 @@ def format_number(number) -> str:
|
|||||||
return number
|
return number
|
||||||
|
|
||||||
|
|
||||||
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
def format_values(dff: pl.DataFrame) -> pl.DataFrame:
|
||||||
def format_function(expr, scale=None):
|
def format_montant(expr, scale=None):
|
||||||
# https://stackoverflow.com/a/78636786
|
# https://stackoverflow.com/a/78636786
|
||||||
expr = expr.cast(pl.String).str.splitn(".", 2)
|
expr = expr.cast(pl.String)
|
||||||
|
expr = expr.str.splitn(".", 2)
|
||||||
|
|
||||||
num = expr.struct[0]
|
num = expr.struct[0]
|
||||||
frac = expr.struct[1]
|
frac = expr.struct[1]
|
||||||
@@ -141,13 +164,29 @@ def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
|||||||
|
|
||||||
frac: pl.Expr = (
|
frac: pl.Expr = (
|
||||||
pl.when(frac.is_not_null() & ~frac.is_in(["0"]))
|
pl.when(frac.is_not_null() & ~frac.is_in(["0"]))
|
||||||
.then("," + frac)
|
.then("," + frac.str.head(2))
|
||||||
.otherwise(pl.lit(""))
|
.otherwise(pl.lit(""))
|
||||||
)
|
)
|
||||||
|
|
||||||
return num + frac + pl.lit(" €")
|
montant: pl.Expr = (
|
||||||
|
pl.when((num + frac) == pl.lit(""))
|
||||||
|
.then(pl.lit(""))
|
||||||
|
.otherwise(num + frac + pl.lit(" €"))
|
||||||
|
)
|
||||||
|
|
||||||
|
return montant
|
||||||
|
|
||||||
|
def format_distance(expr):
|
||||||
|
expr = expr.cast(pl.String)
|
||||||
|
return pl.concat_str(expr, pl.lit(" km"))
|
||||||
|
|
||||||
|
if "montant" in dff.columns:
|
||||||
|
dff = dff.with_columns(pl.col("montant").pipe(format_montant).alias("montant"))
|
||||||
|
if "distance" in dff.columns:
|
||||||
|
dff = dff.with_columns(
|
||||||
|
pl.col("distance").pipe(format_distance).alias("distance")
|
||||||
|
)
|
||||||
|
|
||||||
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
|
|
||||||
return dff
|
return dff
|
||||||
|
|
||||||
|
|
||||||
@@ -157,7 +196,7 @@ def get_annuaire_data(siret: str) -> dict:
|
|||||||
return response.json()["results"][0]
|
return response.json()["results"][0]
|
||||||
|
|
||||||
|
|
||||||
def get_decp_data() -> pl.LazyFrame:
|
def get_decp_data() -> pl.DataFrame:
|
||||||
# Chargement du fichier parquet
|
# Chargement du fichier parquet
|
||||||
# Le fichier est chargé en mémoire, ce qui est plus rapide qu'une base de données pour le moment.
|
# Le fichier est chargé en mémoire, ce qui est plus rapide qu'une base de données pour le moment.
|
||||||
# On utilise polars pour la rapidité et la facilité de manipulation des données.
|
# On utilise polars pour la rapidité et la facilité de manipulation des données.
|
||||||
@@ -186,7 +225,19 @@ def get_decp_data() -> pl.LazyFrame:
|
|||||||
# ça génère une erreur dans la page acheteur (acheteur_data.table) :
|
# ça génère une erreur dans la page acheteur (acheteur_data.table) :
|
||||||
# AttributeError: partially initialized module 'pandas' has no attribute 'NaT' (most likely due to a circular import)
|
# AttributeError: partially initialized module 'pandas' has no attribute 'NaT' (most likely due to a circular import)
|
||||||
|
|
||||||
return lff
|
return lff.collect()
|
||||||
|
|
||||||
|
|
||||||
|
def get_org_data(dff: pl.DataFrame, org_type: str) -> pl.DataFrame:
|
||||||
|
lff = dff.lazy()
|
||||||
|
lff = lff.select(
|
||||||
|
"uid",
|
||||||
|
cs.starts_with(org_type).exclude(
|
||||||
|
f"{org_type}_latitude", f"{org_type}_longitude"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
lff = lff.group_by(cs.starts_with(org_type)).len("Marchés")
|
||||||
|
return lff.collect()
|
||||||
|
|
||||||
|
|
||||||
def get_departements() -> dict:
|
def get_departements() -> dict:
|
||||||
@@ -206,23 +257,35 @@ def get_departement_region(code_postal):
|
|||||||
|
|
||||||
|
|
||||||
def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
||||||
|
debug = os.getenv("DEVELOPMENT", "False").lower() == "true"
|
||||||
schema = lff.collect_schema()
|
schema = lff.collect_schema()
|
||||||
filtering_expressions = filter_query.split(" && ")
|
filtering_expressions = filter_query.split(" && ")
|
||||||
for filter_part in filtering_expressions:
|
for filter_part in filtering_expressions:
|
||||||
col_name, operator, filter_value = split_filter_part(filter_part)
|
col_name, operator, filter_value = split_filter_part(filter_part)
|
||||||
col_type = str(schema[col_name])
|
col_type = str(schema[col_name])
|
||||||
|
if debug:
|
||||||
print("filter_value:", filter_value)
|
print("filter_value:", filter_value)
|
||||||
print("filter_value_type:", type(filter_value))
|
print("filter_value_type:", type(filter_value))
|
||||||
|
print("operator:", operator)
|
||||||
print("col_type:", col_type)
|
print("col_type:", col_type)
|
||||||
|
|
||||||
if col_type == "Date":
|
lff = lff.filter(pl.col(col_name).is_not_null())
|
||||||
# Convertir la colonne en chaînes de caractères
|
|
||||||
lff = dates_to_strings(lff, col_name)
|
|
||||||
|
|
||||||
if operator in ("<", "<=", ">", ">="):
|
if col_type == "Date":
|
||||||
lff = lff.filter(
|
# Convertir la colonne date en chaînes de caractères
|
||||||
pl.col(col_name).is_not_null() & (pl.col(col_name) != pl.lit(""))
|
lff = dates_to_strings(lff, col_name)
|
||||||
)
|
col_type = "String"
|
||||||
|
if col_type == "String":
|
||||||
|
lff = lff.filter(pl.col(col_name) != pl.lit(""))
|
||||||
|
|
||||||
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
|
try:
|
||||||
|
filter_value = int(filter_value)
|
||||||
|
except ValueError:
|
||||||
|
logger.error(f"Invalid numeric filter value: {filter_value}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if operator in ("contains", "<", "<=", ">", ">="):
|
||||||
if operator == "<":
|
if operator == "<":
|
||||||
lff = lff.filter(pl.col(col_name) < filter_value)
|
lff = lff.filter(pl.col(col_name) < filter_value)
|
||||||
elif operator == ">":
|
elif operator == ">":
|
||||||
@@ -231,17 +294,18 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
|||||||
lff = lff.filter(pl.col(col_name) >= filter_value)
|
lff = lff.filter(pl.col(col_name) >= filter_value)
|
||||||
elif operator == "<=":
|
elif operator == "<=":
|
||||||
lff = lff.filter(pl.col(col_name) <= filter_value)
|
lff = lff.filter(pl.col(col_name) <= filter_value)
|
||||||
|
elif operator == "contains":
|
||||||
|
if col_type in ["String", "Date"]:
|
||||||
|
filter_value = filter_value.strip('"')
|
||||||
|
lff = lff.filter(
|
||||||
|
pl.col(col_name).str.contains("(?i)" + filter_value)
|
||||||
|
)
|
||||||
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
try:
|
|
||||||
filter_value = int(filter_value)
|
|
||||||
except ValueError:
|
|
||||||
logger.error(f"Invalid numeric filter value: {filter_value}")
|
|
||||||
continue
|
|
||||||
lff = lff.filter(pl.col(col_name) == filter_value)
|
lff = lff.filter(pl.col(col_name) == filter_value)
|
||||||
|
else:
|
||||||
elif operator == "contains" and col_type in ["String", "Date"]:
|
logger.error(f"Invalid column type: {col_type}")
|
||||||
lff = lff.filter(pl.col(col_name).str.contains("(?i)" + filter_value))
|
else:
|
||||||
|
logger.error(f"Invalid operator: {operator}")
|
||||||
|
|
||||||
# elif operator == 'datestartswith':
|
# elif operator == 'datestartswith':
|
||||||
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
||||||
@@ -268,9 +332,11 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
continue
|
continue
|
||||||
column_object = data_schema.get(column_id)
|
column_object = data_schema.get(column_id)
|
||||||
if column_object:
|
if column_object:
|
||||||
column_name = column_object.get("friendly_name", column_id)
|
column_name = column_object.get("title")
|
||||||
else:
|
else:
|
||||||
column_name = column_id
|
# Si le champ n'est pas dans le schéma, on le skip
|
||||||
|
print(f"Champ innatendu : {column_id}")
|
||||||
|
continue
|
||||||
|
|
||||||
column = {
|
column = {
|
||||||
"name": column_name,
|
"name": column_name,
|
||||||
@@ -284,7 +350,7 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
|
|
||||||
if column_object:
|
if column_object:
|
||||||
tooltip[column_id] = {
|
tooltip[column_id] = {
|
||||||
"value": f"""**{column_object.get("friendly_name")}** ({column_id})
|
"value": f"""**{column_object.get("title")}** ({column_id})
|
||||||
|
|
||||||
"""
|
"""
|
||||||
+ column_object["description"],
|
+ column_object["description"],
|
||||||
@@ -293,7 +359,320 @@ def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tup
|
|||||||
return columns, tooltip
|
return columns, tooltip
|
||||||
|
|
||||||
|
|
||||||
lf = get_decp_data()
|
def get_default_hidden_columns(page):
|
||||||
|
if page == "acheteur":
|
||||||
|
displayed_columns = [
|
||||||
|
"uid",
|
||||||
|
"objet",
|
||||||
|
"dateNotification",
|
||||||
|
"titulaire_id",
|
||||||
|
"titulaire_typeIdentifiant",
|
||||||
|
"titulaire_nom",
|
||||||
|
"distance",
|
||||||
|
"montant",
|
||||||
|
"codeCPV",
|
||||||
|
"dureeRestanteMois",
|
||||||
|
]
|
||||||
|
elif page == "titulaire":
|
||||||
|
displayed_columns = [
|
||||||
|
"uid",
|
||||||
|
"objet",
|
||||||
|
"dateNotification",
|
||||||
|
"acheteur_id",
|
||||||
|
"acheteur_nom",
|
||||||
|
"distance",
|
||||||
|
"montant",
|
||||||
|
"codeCPV",
|
||||||
|
"dureeRestanteMois",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
displayed_columns = os.getenv("DISPLAYED_COLUMNS")
|
||||||
|
if displayed_columns is None:
|
||||||
|
raise ValueError("DISPLAYED_COLUMNS n'est pas configuré")
|
||||||
|
else:
|
||||||
|
displayed_columns = displayed_columns.replace(" ", "").split(",")
|
||||||
|
|
||||||
|
hidden_columns = []
|
||||||
|
|
||||||
|
for col in schema.names():
|
||||||
|
if col in displayed_columns:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
hidden_columns.append(col)
|
||||||
|
return hidden_columns
|
||||||
|
|
||||||
|
|
||||||
|
def get_data_schema() -> dict:
|
||||||
|
# Récupération du schéma des données tabulaires
|
||||||
|
path = os.getenv("DATA_SCHEMA_PATH")
|
||||||
|
if path.startswith("http"):
|
||||||
|
original_schema: dict = get(
|
||||||
|
os.getenv("DATA_SCHEMA_PATH"), follow_redirects=True
|
||||||
|
).json()
|
||||||
|
elif os.path.exists(path):
|
||||||
|
with open(path) as f:
|
||||||
|
original_schema: dict = json.load(f)
|
||||||
|
else:
|
||||||
|
raise Exception(f"Chemin vers le schéma invalide: {path}")
|
||||||
|
|
||||||
|
new_schema = {}
|
||||||
|
|
||||||
|
for col in original_schema["fields"]:
|
||||||
|
new_schema[col["name"]] = col
|
||||||
|
|
||||||
|
new_schema["sourceDataset"] = {
|
||||||
|
"description": "Code de la source des données, avec un lien vers le fichier Open Data dont proviennent les données de ce marché public.",
|
||||||
|
"title": "Source des données",
|
||||||
|
"short_name": "Source",
|
||||||
|
}
|
||||||
|
return new_schema
|
||||||
|
|
||||||
|
|
||||||
|
def track_search(query):
|
||||||
|
if (
|
||||||
|
len(query) >= 4
|
||||||
|
and os.getenv("DEVELOPMENT").lower != "true"
|
||||||
|
and os.getenv("MATOMO_DOMAIN")
|
||||||
|
):
|
||||||
|
if os.getenv("DEVELOPMENT").lower() == "true":
|
||||||
|
url = "https://test.decp.info"
|
||||||
|
else:
|
||||||
|
url = "https://decp.info"
|
||||||
|
params = {
|
||||||
|
"idsite": os.getenv("MATOMO_ID_SITE"),
|
||||||
|
"url": url,
|
||||||
|
"rec": "1",
|
||||||
|
"action_name": "front_page_search",
|
||||||
|
"rand": uuid.uuid4().hex,
|
||||||
|
"apiv": "1",
|
||||||
|
"h": localtime().tm_hour,
|
||||||
|
"m": localtime().tm_min,
|
||||||
|
"s": localtime().tm_sec,
|
||||||
|
"search": query,
|
||||||
|
"token_auth": os.getenv("MATOMO_TOKEN"),
|
||||||
|
}
|
||||||
|
post(
|
||||||
|
url=f"https://{os.getenv('MATOMO_DOMAIN')}/matomo.php",
|
||||||
|
params=params,
|
||||||
|
).raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
||||||
|
"""
|
||||||
|
Search in either 'acheteur' or 'titulaire' DataFrame.
|
||||||
|
|
||||||
|
:param dff: Polars DataFrame with acheteur or titulaire columns
|
||||||
|
:param query: User search string
|
||||||
|
:param org_type: 'acheteur' or 'titulaire'
|
||||||
|
:return: Filtered DataFrame with 'matches' column
|
||||||
|
"""
|
||||||
|
if not query.strip():
|
||||||
|
return dff.select(pl.lit(False).alias("matches"))
|
||||||
|
|
||||||
|
# Enregistrement des recherche dans Matomo
|
||||||
|
track_search(query)
|
||||||
|
|
||||||
|
# Normalize query
|
||||||
|
normalized_query = unidecode(query.strip()).upper()
|
||||||
|
tokens = [" " + t.strip() for t in normalized_query.split() if t.strip()]
|
||||||
|
|
||||||
|
# Define columns based on entity type
|
||||||
|
cols = [
|
||||||
|
f"{org_type}_id",
|
||||||
|
f"{org_type}_nom",
|
||||||
|
f"{org_type}_departement_nom",
|
||||||
|
f"{org_type}_departement_code",
|
||||||
|
f"{org_type}_commune_nom",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Concatenate all fields into one string per row
|
||||||
|
org_str = pl.concat_str(pl.lit(" "), pl.col(cols), separator=" ").str.replace(
|
||||||
|
"-", " "
|
||||||
|
)
|
||||||
|
|
||||||
|
# For each token, create a boolean column: True if token is found
|
||||||
|
token_matches = []
|
||||||
|
for token in tokens:
|
||||||
|
token_match = org_str.str.contains(token).alias(f"token_{token}")
|
||||||
|
token_matches.append(token_match)
|
||||||
|
|
||||||
|
# Count how many tokens match per row
|
||||||
|
match_score = pl.sum_horizontal(token_matches).alias("match_score")
|
||||||
|
|
||||||
|
# For each token, create a boolean column: True if token is found
|
||||||
|
token_matches = []
|
||||||
|
for token in tokens:
|
||||||
|
token_match = org_str.str.contains(token).alias(f"token_{token}")
|
||||||
|
token_matches.append(token_match)
|
||||||
|
|
||||||
|
# Sélection des colonnes
|
||||||
|
if org_type == "acheteur":
|
||||||
|
dff = dff.select(cols + ["Marchés"])
|
||||||
|
if org_type == "titulaire":
|
||||||
|
dff = dff.select(cols + ["Marchés", "titulaire_typeIdentifiant"])
|
||||||
|
|
||||||
|
# Apply and filter
|
||||||
|
dff = (
|
||||||
|
dff.with_columns(token_matches + [match_score])
|
||||||
|
.filter(pl.col("match_score") == len(tokens))
|
||||||
|
.sort("Marchés", descending=True)
|
||||||
|
.drop([f"token_{token}" for token in tokens])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Format result
|
||||||
|
dff = add_links(dff, target="")
|
||||||
|
dff = dff.with_columns(
|
||||||
|
pl.concat_str(
|
||||||
|
pl.col(f"{org_type}_departement_nom"),
|
||||||
|
pl.lit(" ("),
|
||||||
|
pl.col(f"{org_type}_departement_code"),
|
||||||
|
pl.lit(")"),
|
||||||
|
).alias("Département")
|
||||||
|
)
|
||||||
|
|
||||||
|
dff = dff.select(f"{org_type}_id", f"{org_type}_nom", "Département", "Marchés")
|
||||||
|
|
||||||
|
return dff
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_table_data(
|
||||||
|
data, data_timestamp, filter_query, page_current, page_size, sort_by
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Fonction de préparation des données pour les datatables, afin de permettre une gestion fine des logiques,
|
||||||
|
notamment pour les filtres et les tris.
|
||||||
|
:param data
|
||||||
|
:param data_timestamp:
|
||||||
|
:param filter_query:
|
||||||
|
:param page_current:
|
||||||
|
:param page_size:
|
||||||
|
:param sort_by:
|
||||||
|
:param search_params:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
if os.getenv("DEVELOPMENT").lower() == "true":
|
||||||
|
print(" + + + + + + + + + + + + + + + + + + ")
|
||||||
|
|
||||||
|
# Récupération des données
|
||||||
|
if isinstance(data, list):
|
||||||
|
lff: pl.LazyFrame = pl.LazyFrame(data, strict=False, infer_schema_length=5000)
|
||||||
|
else:
|
||||||
|
lff: pl.LazyFrame = df.lazy() # start from the original data
|
||||||
|
|
||||||
|
# if search_params:
|
||||||
|
# if "filtres" in search_params:
|
||||||
|
# filter_query = search_params["filtres"][0]
|
||||||
|
#
|
||||||
|
# if "tris" in search_params:
|
||||||
|
# try:
|
||||||
|
# sort_by = json.loads(search_params["tris"][0])
|
||||||
|
# except json.JSONDecodeError:
|
||||||
|
# pass
|
||||||
|
#
|
||||||
|
# if "colonnes" in search_params:
|
||||||
|
# try:
|
||||||
|
# hidden_columns = json.loads(search_params["colonnes"][0])
|
||||||
|
# print(hidden_columns)
|
||||||
|
# lff = lff.drop(hidden_columns)
|
||||||
|
# except json.JSONDecodeError:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
# Application des filtres
|
||||||
|
if filter_query:
|
||||||
|
lff = filter_table_data(lff, filter_query)
|
||||||
|
|
||||||
|
# Application des tris
|
||||||
|
if len(sort_by) > 0:
|
||||||
|
lff = sort_table_data(lff, sort_by)
|
||||||
|
|
||||||
|
# Matérialisation des filtres
|
||||||
|
dff: pl.DataFrame = lff.collect()
|
||||||
|
height = dff.height
|
||||||
|
|
||||||
|
if height > 0:
|
||||||
|
nb_rows = f"{format_number(height)} lignes ({format_number(dff.select('uid').unique().height)} marchés)"
|
||||||
|
else:
|
||||||
|
nb_rows = "0 lignes (0 marchés)"
|
||||||
|
|
||||||
|
# Pagination des données
|
||||||
|
start_row = page_current * page_size
|
||||||
|
# end_row = (page_current + 1) * page_size
|
||||||
|
dff = dff.slice(start_row, page_size)
|
||||||
|
|
||||||
|
# Tout devient string
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
|
||||||
|
# Remplace les strings null par "", mais pas les numeric null
|
||||||
|
dff = dff.fill_null("")
|
||||||
|
|
||||||
|
# Ajout des liens vers l'annuaire des entreprises
|
||||||
|
dff = add_links(dff)
|
||||||
|
|
||||||
|
# Ajout des liens vers les fichiers Open Data
|
||||||
|
if "sourceFile" in dff.columns:
|
||||||
|
dff = add_resource_link(dff)
|
||||||
|
|
||||||
|
# Formatage des montants
|
||||||
|
if height > 0:
|
||||||
|
dff = format_values(dff)
|
||||||
|
|
||||||
|
# Récupération des colonnes et tooltip
|
||||||
|
columns, tooltip = setup_table_columns(dff)
|
||||||
|
|
||||||
|
dicts = dff.to_dicts()
|
||||||
|
|
||||||
|
# Propriétés du bouton de téléchargement
|
||||||
|
download_disabled, download_text, download_title = get_button_properties(height)
|
||||||
|
|
||||||
|
return (
|
||||||
|
dicts,
|
||||||
|
columns,
|
||||||
|
tooltip,
|
||||||
|
data_timestamp + 1,
|
||||||
|
nb_rows,
|
||||||
|
download_disabled,
|
||||||
|
download_text,
|
||||||
|
download_title,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_button_properties(height):
|
||||||
|
if height > 65000:
|
||||||
|
download_disabled = True
|
||||||
|
download_text = "Téléchargement désactivé au-delà de 65 000 lignes"
|
||||||
|
download_title = "Excel ne supporte pas d'avoir plus de 65 000 URLs dans une même feuille de calcul. Contactez-moi pour me présenter votre besoin en téléchargement afin que je puisse adapter la solution."
|
||||||
|
elif height == 0:
|
||||||
|
download_disabled = True
|
||||||
|
download_text = "Pas de données à télécharger"
|
||||||
|
download_title = ""
|
||||||
|
else:
|
||||||
|
download_disabled = False
|
||||||
|
download_text = "Télécharger au format Excel"
|
||||||
|
download_title = ""
|
||||||
|
return download_disabled, download_text, download_title
|
||||||
|
|
||||||
|
|
||||||
|
def invert_columns(columns):
|
||||||
|
"""
|
||||||
|
Renvoie les colonnes du schéma non spécifiées en paramètre. Utile pour passer d'une colonnes masquées à une liste de colonnes affichées, et vice versa.
|
||||||
|
|
||||||
|
:param columns:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
inverted_columns = []
|
||||||
|
for column in schema.names():
|
||||||
|
if column not in columns:
|
||||||
|
inverted_columns.append(column)
|
||||||
|
return inverted_columns
|
||||||
|
|
||||||
|
|
||||||
|
df: pl.DataFrame = get_decp_data()
|
||||||
|
schema = df.collect_schema()
|
||||||
|
|
||||||
|
df_acheteurs = get_org_data(df, "acheteur")
|
||||||
|
df_titulaires = get_org_data(df, "titulaire")
|
||||||
|
|
||||||
departements = get_departements()
|
departements = get_departements()
|
||||||
domain_name = (
|
domain_name = (
|
||||||
"test.decp.info" if os.getenv("DEVELOPMENT").lower() == "true" else "decp.info"
|
"test.decp.info" if os.getenv("DEVELOPMENT").lower() == "true" else "decp.info"
|
||||||
@@ -306,10 +685,4 @@ meta_content = {
|
|||||||
"Pour une commande publique accessible à toutes et tous."
|
"Pour une commande publique accessible à toutes et tous."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
data_schema = get_data_schema()
|
||||||
# Récupération du schéma des données tabulaires
|
|
||||||
data_schema: dict = get(os.getenv("DATA_SCHEMA_PATH"), follow_redirects=True).json()
|
|
||||||
data_schema["source"] = {
|
|
||||||
"description": "Code de la source des données, avec un lien vers le fichier Open Data dont proviennent les données de ce marché public.",
|
|
||||||
"friendly_name": "Source des données",
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user