diff --git a/lib/api/district/models.js b/lib/api/district/models.js index 3f2c112b..e9e1f1df 100644 --- a/lib/api/district/models.js +++ b/lib/api/district/models.js @@ -5,9 +5,9 @@ export const getDistrict = districtID => District.findByPk(districtID, {raw: tru export const getDistricts = districtIDs => District.findAll({where: {id: districtIDs}, raw: true}) -export const getDistrictFromCog = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) +export const getDistrictsFromCog = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) -export const getDistrictsFromCog = async cogList => { +export const getDistrictsFromCogList = async cogList => { const districts = await District.findAll({where: {meta: {insee: {cog: {[Op.or]: cogList}}}}, raw: true}) const districtsByInseeCode = districts.reduce( (acc, district) => { diff --git a/lib/api/district/utils.js b/lib/api/district/utils.js index e8190a4c..fb1669af 100644 --- a/lib/api/district/utils.js +++ b/lib/api/district/utils.js @@ -1,7 +1,7 @@ import Papa from 'papaparse' import {checkDataFormat, dataValidationReportFrom, checkIdsIsUniq, checkIdsIsVacant, checkIdsIsAvailable, checkDataShema, checkIdsShema} from '../helper.js' import {banID} from '../schema.js' -import {getDistricts, getDistrictsFromCog} from './models.js' +import {getDistricts, getDistrictsFromCogList} from './models.js' import {banDistrictSchema} from './schema.js' const getExistingDistrictIDs = async districtIDs => { @@ -86,7 +86,7 @@ export async function formatDataNova(postalFile) { skipEmptyLines: true, }) - const districts = await getDistrictsFromCog( + const districts = await getDistrictsFromCogList( dataRaw.data.map(({codeInsee}) => codeInsee) )