Skip to content

Commit

Permalink
Merge pull request #509 from BaseAdresseNationale/antoineludeau/expor…
Browse files Browse the repository at this point in the history
…t-district-config

Added district config in export to exploitation db
  • Loading branch information
antoineludeau authored Dec 19, 2024
2 parents c25f112 + a004b59 commit ec3b087
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions lib/api/consumers/format-to-legacy-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const districtsAddressesExtraDataIndex = districtsAddressesExtraData.reduce((acc
}, {})

export const formatDistrictDataForLegacy = async (district, {totalCommonToponymRecords, totalSpecifCommonToponymRecords, totalAddressRecords, totalAddressCertifiedRecords}) => {
const {id, meta, labels} = district
const {id, meta, labels, config} = district
const {insee: {cog}} = meta

// District data from administrative division
Expand Down Expand Up @@ -65,12 +65,13 @@ export const formatDistrictDataForLegacy = async (district, {totalCommonToponymR
idRevision: meta?.bal?.idRevision,
dateRevision: meta?.bal?.dateRevision,
composedAt: new Date(),
withBanId: true
withBanId: true,
config
}
}

export const formatCommonToponymDataForLegacy = async (commonToponym, {district, pseudoCodeVoieGenerator, commonToponymLegacyIDCommonToponymIDMap, commonToponymLegacyIDSet, gazetteerFinder}) => {
const {labels: districtLabels, meta: {insee: {cog}}} = district
const {labels: districtLabels, meta: {insee: {cog}}, config} = district
const {id, districtID, geometry, labels, meta, updateDate, addressCount, certifiedAddressCount, bbox} = commonToponym

// Labels
Expand Down Expand Up @@ -141,7 +142,9 @@ export const formatCommonToponymDataForLegacy = async (commonToponym, {district,
tiles: meta?.geography?.tiles,
position: legacyPosition,
displayBBox: commonToponymBbox,
dateMAJ: legacyUpdateDate
dateMAJ: legacyUpdateDate,
withBanId: true,
config
}
}

Expand All @@ -168,12 +171,14 @@ export const formatCommonToponymDataForLegacy = async (commonToponym, {district,
tiles: meta?.geography?.tiles,
sources: ['bal'],
nbNumeros: Number.parseInt(addressCount, 10),
nbNumerosCertifies: Number.parseInt(certifiedAddressCount, 10)
nbNumerosCertifies: Number.parseInt(certifiedAddressCount, 10),
withBanId: true,
config
}
}

export const formatAddressDataForLegacy = async (address, {district, commonToponymLegacyIDCommonToponymIDMap, addressLegacyIDSet, gazetteerFinder}) => {
const {meta: {insee: {cog}}} = district
const {meta: {insee: {cog}}, config} = district
const {id, mainCommonToponymID, secondaryCommonToponymIDs, districtID, number, suffix, positions, labels, meta, updateDate, certified, bbox} = address

// Labels
Expand Down Expand Up @@ -240,7 +245,9 @@ export const formatAddressDataForLegacy = async (address, {district, commonTopon
certifie: certified,
codePostal: meta?.laposte?.codePostal,
libelleAcheminement: meta?.laposte?.libelleAcheminement,
adressesOriginales: [address]
adressesOriginales: [address],
withBanId: true,
config
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/models/commune.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ async function getPopulatedCommune(codeCommune) {
'typeComposition',
'displayBBox',
'idRevision',
'dateRevision'
'dateRevision',
'config',
]

const commune = await mongo.db.collection('communes')
Expand Down

0 comments on commit ec3b087

Please sign in to comment.