-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change postal code calculation #369
base: master
Are you sure you want to change the base?
Conversation
36d05be
to
05505a1
Compare
import {District} from '../../util/sequelize.js' | ||
|
||
export const getDistrict = districtID => District.findByPk(districtID, {raw: true}) | ||
|
||
export const getDistricts = districtIDs => District.findAll({where: {id: districtIDs}, raw: true}) | ||
|
||
export const getDistrictsFromCog = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) | ||
export const getDistrictFromCog = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) | ||
export const getDistrictFromCog = cog => District.findAll({where: {meta: {insee: {cog}}}, raw: true}) | ||
|
||
export const getDistrictsFromCog = async cogList => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getDistrictsFromCog = async cogList => { | |
export const getDistrictsFromCogList = async cogList => { |
@@ -189,7 +190,7 @@ app.get('/cog/:cog', analyticsMiddleware, async (req, res) => { | |||
let response | |||
try { | |||
const {cog} = req.params | |||
const districts = await getDistrictsFromCog(cog) | |||
const districts = await getDistrictFromCog(cog) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const districts = await getDistrictFromCog(cog) | |
const districts = await getDistrictsFromCog(cog) |
Il faudrait aussi renommer le fichier de migration de .js en .cjs |
await apiQueue.add( | ||
{dataType: 'district', jobType: 'updatePostalCode', data: postalFile, statusID}, | ||
{jobId: statusID, removeOnComplete: true} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) | |
) | |
response = { | |
date: new Date(), | |
status: 'success', | |
message: `Check the status of your request : ${BAN_API_URL}/job-status/${statusID}`, | |
response: {statusID}, | |
} |
Note : penser à modifier la fonction "extractRelatedDistrictIDs" du fichier api-consumer.js. Comportement à discuter. |
// On February 2024 the postal file url is : | ||
// https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/raw | ||
const {url} = req.query | ||
const postalFile = await fetch(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const postalFile = await fetch(url) | |
const postalFileRawResponse = await fetch(url) | |
const postalFile = await postalFileRawResponse.text() |
@@ -215,4 +216,59 @@ app.get('/cog/:cog', analyticsMiddleware, async (req, res) => { | |||
res.send(response) | |||
}) | |||
|
|||
app.route('/codePostal', auth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quand je test avec l'URL GET /district/codePostal, "express" considère que "codePostal" est un UUID et que je j'essaye de récupérer les infos d'un district.
Cette PR vise à améliorer le calcul des codes postaux dans la base postgres à l'aide de données fournies par La Poste :
Pour cela, cette PR ajoute :
fix intégrer les données CP de datanova - migration #363