Skip to content

Commit

Permalink
Fix: rename getDistrict functions
Browse files Browse the repository at this point in the history
  • Loading branch information
FLoreauIGN committed Apr 18, 2024
1 parent b76dd70 commit ab0d3e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/api/district/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/api/district/utils.js
Original file line number Diff line number Diff line change
@@ -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 => {
Expand Down Expand Up @@ -86,7 +86,7 @@ export async function formatDataNova(postalFile) {
skipEmptyLines: true,
})

const districts = await getDistrictsFromCog(
const districts = await getDistrictsFromCogList(
dataRaw.data.map(({codeInsee}) => codeInsee)
)

Expand Down

0 comments on commit ab0d3e5

Please sign in to comment.