Skip to content

fix: score B instead of E for subventions over-budget + update methodology#495

Merged
cyrilledaily merged 4 commits intodataforgoodfr:mainfrom
cyrilledaily:feature/subventions-score-over-budget
Feb 16, 2026
Merged

fix: score B instead of E for subventions over-budget + update methodology#495
cyrilledaily merged 4 commits intodataforgoodfr:mainfrom
cyrilledaily:feature/subventions-score-over-budget

Conversation

@cyrilledaily
Copy link
Collaborator

Summary

  • Backend: Change get_score_from_tp() in bareme_enricher.py so that subventions ratios >105% return score B instead of E. Over-declaration still demonstrates a real transparency effort and should not be penalized the same as "no data".
  • Frontend: Update the scoring grid on the /methodologie page to reflect the new logic — move ">105%" from score E to score B.

Files changed

  • back/scripts/enrichment/bareme_enricher.py — scoring logic + docstrings
  • front/app/(comprendre)/methodologie/page.tsx — scoring grid display

Test plan

  • Verify that a collectivité with >105% subventions ratio now receives score B
  • Verify the methodology page correctly shows the updated scoring grid
  • Check that the aggregate score calculation still works correctly

cc @jb-delafosse @m4xim1nus for review

Made with Cursor

@github-actions
Copy link
Contributor

:octocat: Preview is deploying...

Please wait while the preview is deploying on Clever Cloud...

ℹ️ Name 🔗 Infos & links
🌱 Deploying commit 509c6b5
👁️ Preview Generating preview app...

@m4xim1nus
Copy link
Collaborator

m4xim1nus commented Feb 16, 2026

RAS — logique métier cohérente entre backend et frontend. La docstring est maintenant alignée avec les vrais seuils du code (corrige un décalage pré-existant).

@jb-delafosse jb-delafosse force-pushed the feature/subventions-score-over-budget branch from 509c6b5 to d97d36d Compare February 16, 2026 19:49
Copy link
Collaborator

@jb-delafosse jb-delafosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juste ces 2 tests à updates FAILED back/tests/test_bareme_enricher.py::TestGetScoreFromTp::test_score_e_for_over_declaration
FAILED back/tests/test_bareme_enricher.py::TestGetScoreFromTp::test_boundary_values

cyrilledaily pushed a commit to cyrilledaily/13_eclaireur_public that referenced this pull request Feb 16, 2026
Align test_score_e_for_over_declaration (renamed to
test_score_b_for_over_declaration) and test_boundary_values with the
new scoring logic where >105% returns B, not E.

Fixes review comment by @jb-delafosse on PR dataforgoodfr#495.

Co-authored-by: Cursor <cursoragent@cursor.com>
CyrilleDS and others added 4 commits February 16, 2026 21:40
When declared subventions exceed the budgeted amount (ratio >105%), the
previous logic penalized these collectivites with an E score, treating
over-declaration the same as no data. Over-declaration still demonstrates
a real transparency effort and is now scored B instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
…over-budget

Move the ">105%" case from score E to score B in the subventions scoring
grid. Score E now only covers "0% - no data". Score B now reads
"50% to 95% or over 105% (over-declaration)" to match the updated
backend logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align test_score_e_for_over_declaration (renamed to
test_score_b_for_over_declaration) and test_boundary_values with the
new scoring logic where >105% returns B, not E.

Fixes review comment by @jb-delafosse on PR dataforgoodfr#495.

Co-authored-by: Cursor <cursoragent@cursor.com>
PR dataforgoodfr#498 added a _schema_version column to clean_row output but didn't
update test_marches_public_dataframes to expect 6 columns instead of 5.
Also apply ruff format fixes to marches_enricher.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cyrilledaily cyrilledaily force-pushed the feature/subventions-score-over-budget branch from a68c479 to 1e40215 Compare February 16, 2026 20:41
@cyrilledaily cyrilledaily merged commit 232267d into dataforgoodfr:main Feb 16, 2026
2 of 3 checks passed
m4xim1nus added a commit that referenced this pull request Feb 18, 2026
- Remplace les 4 KPIs par des valeurs plus signifiantes et sans ambiguïté :
  collectivités soumises à la loi, montant total MP+Sub depuis 2016 (hors
  aberrations), % score A/B marchés publics 2024, % subventions publiées 2024
- Aligne la logique de calcul sur fetchPerspectivesData : même condition
  "soumises" (communes ≥ 3500 hab + DEP/REG/GRP), même filtre outliers
- Corrige SCORE_TO_RANGE (B/E) désynchronisé depuis le fix #495 :
  E = "0% - Aucune donnée", B inclut "ou > 105%" (sur-déclaration)
- Passe KPI_REFERENCE_YEAR à 2024 pour cohérence avec le reste du site
- Ajoute formatMilliardsPrice() pour un affichage "X,X Md€" robuste
- Supprime 5 fetchers KPI orphelins remplacés par la nouvelle requête unifiée

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cyrilledaily pushed a commit that referenced this pull request Feb 18, 2026
- Remplace les 4 KPIs par des valeurs plus signifiantes et sans ambiguïté :
  collectivités soumises à la loi, montant total MP+Sub depuis 2016 (hors
  aberrations), % score A/B marchés publics 2024, % subventions publiées 2024
- Aligne la logique de calcul sur fetchPerspectivesData : même condition
  "soumises" (communes ≥ 3500 hab + DEP/REG/GRP), même filtre outliers
- Corrige SCORE_TO_RANGE (B/E) désynchronisé depuis le fix #495 :
  E = "0% - Aucune donnée", B inclut "ou > 105%" (sur-déclaration)
- Passe KPI_REFERENCE_YEAR à 2024 pour cohérence avec le reste du site
- Ajoute formatMilliardsPrice() pour un affichage "X,X Md€" robuste
- Supprime 5 fetchers KPI orphelins remplacés par la nouvelle requête unifiée

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cyrilledaily pushed a commit that referenced this pull request Feb 18, 2026
- Remplace les 4 KPIs par des valeurs plus signifiantes et sans ambiguïté :
  collectivités soumises à la loi, montant total MP+Sub depuis 2016 (hors
  aberrations), % score A/B marchés publics 2024, % subventions publiées 2024
- Aligne la logique de calcul sur fetchPerspectivesData : même condition
  "soumises" (communes ≥ 3500 hab + DEP/REG/GRP), même filtre outliers
- Corrige SCORE_TO_RANGE (B/E) désynchronisé depuis le fix #495 :
  E = "0% - Aucune donnée", B inclut "ou > 105%" (sur-déclaration)
- Passe KPI_REFERENCE_YEAR à 2024 pour cohérence avec le reste du site
- Ajoute formatMilliardsPrice() pour un affichage "X,X Md€" robuste
- Supprime 5 fetchers KPI orphelins remplacés par la nouvelle requête unifiée

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants