Skip to content
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

[DATABASE] Geoloc enrichment #271

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

ChristopheTrannoy
Copy link

Add database enrichment script :

add routes :
/api/reverseGeocode (double latitude, double longitude)
/api/launchDBEnrichmentScript (optional string country (countryCode eg: fr), optional string type (can only be ‘all’), optional string detail (can only be ‘country’, ‘region’, ‘county’, ‘city’))
/api/findByCountry (optional string country (countryCode eg: fr))

Here’s API key has to be specified in services/ReverseGeocodingService.js to properly test.

DBEnrichment.js Show resolved Hide resolved
}
}

update(entry);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faudrait attendre le résultat de cette update pour savoir si il s'est bien passé ou pas necessaire ?

Comment on lines +28 to +42
const req = http.request(options, (res) => {
let chunksOfData = [];
res.on('data', (data) => {
chunksOfData.push(data);
});
res.on('end', () => {
let response = Buffer.concat(chunksOfData);
let json = JSON.parse(response);
resolve(json);
});
});
req.end();
req.on('error', (err) => {
resolve({ msg: err });
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code dupliqué : Il y a exactement le meme code lignes 92 à 106

all.json Show resolved Hide resolved
DBEnrichment.js Show resolved Hide resolved
api/services/DBEnrichmentService.js Show resolved Hide resolved
@bsoufflet
Copy link
Contributor

@ArthurLeblanc @ChristopheTrannoy : Je viens de faire une première partie des commentaires sur cette pull request. Mais je n'ai pas encore terminé. Je finirai demain soir ;)

const options = {
host: HOST,
port: PORT,
path: '/api/entries/updateOneAdministrative',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cela semble un des problèmes d’être passé par les API plutôt que directement par le connecteur de BDD. Ici on se retrouve a utiliser une nouvelle route updateOneAdministrative d'update qui n'est pas protégé (n'importe qui peut update une cavité ! SI vous voulez continuer à utiliser l'API plutot que la BDD directement il faudrait ajouter une protection minimaliste sur la route updateOneAdministrative pour éviter qu'elle puisse etre utiliser par n'importe qui. Par exemple en la limitant à un appel depuis la meme IP ? ...

DBEnrichment.js Show resolved Hide resolved
DBEnrichment.js Show resolved Hide resolved
* Main of the DBEnrichment script.
*/
async function enrichment() {
findAllEntries(process.argv[2]).then(async function(res) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce findAllEntries est un peu trop brutal et pas scalable. Que va t'il se passer si nous avions 200000 cavités ? Nous aurions en memoire un tableau de 200000 entrées à traiter ? Il faudrait plutot fonctionner par batch avec des LIMIT SQL. Je récupère de 0 à 1000 cavités puis de 1001 à 2000, ...

api/controllers/EntryController.js Show resolved Hide resolved
config/policies.js Show resolved Hide resolved
config/policies.js Show resolved Hide resolved
config/policies.js Show resolved Hide resolved
config/routes.js Show resolved Hide resolved
config/routes.js Show resolved Hide resolved
@bsoufflet
Copy link
Contributor

Je viens de finir de review cette PR ;) Quelques changements à faire avant de pouvoir merge ;)

Base automatically changed from rc to develop March 9, 2021 22:53
@Clm-Roig Clm-Roig changed the title Feature/database enrichment [DATABASE] Geoloc enrichment Dec 18, 2022
@urien
Copy link
Contributor

urien commented Mar 25, 2023

Travail en cours par @vmarseguerra suite à #1160 qui remplacera le travail décrit ici

@bsoufflet bsoufflet marked this pull request as draft April 4, 2023 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants