Skip to content

Commit

Permalink
fix: Patch la liste des EPCI pour normaliser les metropôles.
Browse files Browse the repository at this point in the history
Un ticket à éte ouvert chez etalab : datagouv/decoupage-administratif#42
  • Loading branch information
baptou12 committed Oct 19, 2023
1 parent 113efb1 commit be0cdad
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions backend/lib/stats/institutions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from "dayjs"
import epci from "@etalab/decoupage-administratif/data/epci.json" assert { type: "json" }
import epciList from "@etalab/decoupage-administratif/data/epci.json" assert { type: "json" }

import Simulations from "../../models/simulation.js"
import benefits from "../../../data/all.js"
Expand Down Expand Up @@ -63,11 +63,29 @@ function getBenefitCountPerEPCI(): Count {
)
}

// Temporary patch to fix MET69 type
// An issue has been opened on the data repository:
// https://github.com/etalab/decoupage-administratif/issues/42
// TODO: remove this patch when the issue is fixed
function patchEpciList(epci) {
return epci.map((epci) => {
if (epci.type === "MET69") {
return {
...epci,
type: "METRO",
}
}

return epci
})
}

export default async function getInstitutionsData() {
const epciPatched = patchEpciList(epciList)
const simulationNumberPerEPCI = await getSimulationCountPerEPCI()
const benefitCountPerEPCI = getBenefitCountPerEPCI()

return epci.map((epci) => {
return epciPatched.map((epci) => {
return {
name: epci.nom,
code: epci.code,
Expand Down

0 comments on commit be0cdad

Please sign in to comment.