Skip to content

Commit

Permalink
Merge pull request #108 from IGNF/maj_er_product
Browse files Browse the repository at this point in the history
recherche par date de depublication sur er/product + supression champ de recherche "sale" non utilisé
  • Loading branch information
MFrangi authored May 21, 2024
2 parents c7b1b84 + fe129fb commit 9861a55
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
20 changes: 18 additions & 2 deletions controllers/er/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ function createErProxy(featureTypeName,typeSearch){
});
}
}

// For params depublication_date select between 2 dates

if((params.depubli_date_deb) && (params.depubli_date_fin)) {
params.field_depublication_date = params.depubli_date_deb +'T00:00:00Z;'+ params.depubli_date_fin+'T23:59:59Z';
params = _.omit(params,'depubli_date_deb');
params = _.omit(params,'depubli_date_fin');
} else {
if((params.depubli_date_deb) || (params.depubli_date_fin)) {
return res.status(400).send({
code: 400,
message: 'Utilisation des dates de depublication avec une date de fin et une date de debut avec moins de 6 mois entre les 2 dates.'
});
}
}
}

//For _propertyNames, we need to transform the string in Array
Expand Down Expand Up @@ -171,14 +186,15 @@ var productValidators = erValidators.concat([
check('code_ean').optional().isAlphanumeric(),
check('code_article').optional().isString(),
check('name').optional().isString(),
check('sale').optional().isNumeric(),
check('type').optional().isString(),
check('publication_date').optional().isString(),
check('date_maj_deb').optional().isString(), // Param ne servant que pour admin
check('date_maj_fin').optional().isString(), // Param ne servant que pour admin
check('admin').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le champ admin doit être Y ou N'),
check('publi_date_deb').optional().isString(), // Param ne servant que pour admin
check('publi_date_fin').optional().isString() // Param ne servant que pour admin
check('publi_date_fin').optional().isString(), // Param ne servant que pour admin
check('depubli_date_deb').optional().isString(), // Param ne servant que pour admin
check('depubli_date_fin').optional().isString() // Param ne servant que pour admin

]);

Expand Down
19 changes: 13 additions & 6 deletions doc/er.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ paths:
in: query
type: string
required: false

- name: sale
in: query
type: string
required: false

- name: publication_date
in: query
Expand Down Expand Up @@ -81,7 +76,19 @@ paths:

- name: publi_date_fin
in: query
description: Date de publication de fin sous la forme AAAA-MM-JJ
description: Date de publication fin sous la forme AAAA-MM-JJ
type: string
require: false

- name: depubli_date_deb
in: query
description: Date de dépublication début sous la forme AAAA-MM-JJ
type: string
require: false

- name: depubli_date_fin
in: query
description: Date de dépublication fin sous la forme AAAA-MM-JJ
type: string
require: false

Expand Down
4 changes: 4 additions & 0 deletions lib/buildErCqlFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ function buildErCqlFilter(params) {
var value_date_publication = params[name].split(';');
parts.push('publication_date AFTER '+ value_date_publication[0]+' AND publication_date BEFORE '+ value_date_publication[1]);

} else if (name == 'field_depublication_date'){
var value_date_depublication = params[name].split(';');
parts.push('deleted_at AFTER '+ value_date_depublication[0]+' AND deleted_at BEFORE '+ value_date_depublication[1]);

} else if (name == 'namepr') { //Traiter le cas du produit avec le parametre name
parts.push(' name ILIKE \'%'+ params[name] + '%\' OR name_complement ILIKE \'%'+ params[name] + '%\'');

Expand Down

0 comments on commit 9861a55

Please sign in to comment.