-
Notifications
You must be signed in to change notification settings - Fork 17
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
Communes by dep #47
Communes by dep #47
Conversation
cc @jdesboeufs |
Quelle honte. -1.2%, pire que le CAC 40. |
@@ -178,6 +178,33 @@ paths: | |||
schema: | |||
$ref: '#/definitions/Error' | |||
|
|||
/departements/{code}/communes: | |||
get: | |||
summary: Renvoi les communes du d'un département |
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.
Typo
Better? @jdesboeufs |
@@ -83,11 +83,19 @@ app.get('/departements/:code', initDepartementFields, function (req, res) { | |||
}); | |||
|
|||
app.get('/departements/:code/communes', initCommuneFields, initCommuneFormat, function (req, res) { | |||
let communes = dbCommunes.queryByDep(req.params.code); | |||
if (!communes) { | |||
let departement = dbDepartements.queryByCode(req.params.code)[0]; |
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.
Si le résultat est vide, tu vas avoir une exception et donc une erreur 500.
Ça veut dire qu'il manque un test d'intégration avec la 404 attendue.
const matching = dbDepartements.queryByCode(req.params.code);
if (match.length === 0) {
res.sendStatus(404);
} else {
const departement = matching[0];
/// ...
}
Enfin dans l'esprit quoi.
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.
Ou du coup :
if (dbDepartements.queryByCode(req.params.code) === 0) {
// Booom
} else {
// Good
}
Last one? @jdesboeufs |
@@ -83,11 +83,10 @@ app.get('/departements/:code', initDepartementFields, function (req, res) { | |||
}); | |||
|
|||
app.get('/departements/:code/communes', initCommuneFields, initCommuneFormat, function (req, res) { | |||
let departement = dbDepartements.queryByCode(req.params.code)[0]; | |||
if (!departement) { | |||
let communes = dbCommunes.queryByDep(req.params.code); |
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.
On ne s'est pas compris.
On cherche à vérifier l'existence du département, pas qu'il contienne des communes.
Il manque la recherche standard, à savoir via |
Fix #28 |
Fini. |
Réf #31