Skip to content

Commit

Permalink
change api
Browse files Browse the repository at this point in the history
  • Loading branch information
folland87 committed Jan 30, 2025
1 parent feb0cb7 commit faf86aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
36 changes: 3 additions & 33 deletions src/api/commons/queries/sirene-updates.query.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,15 @@ const structQuery = [
emails: { $ifNull: ['$emails', []] },
href: { $concat: ['/structures/', '$id'] },
legalcategory: { $ifNull: ['$legalcategory', {}] },
structureStatus: { $ifNull: ['$structureStatus', null] },
structureStatus: { $ifNull: ['$structureStatus', 'active'] },
},
},
];
export default [
{
$group: {
_id: "$paysage",
siren: { $first: "$siren" },
siret: { $first: "$siret" },
id: { $first: "$paysage" },
type: { $first: "$type" },
lastModificationDate: { $max: "$lastChecked" },
updates: {
$push: {
$cond: {
if: { $eq: ["$changeType", "change"] },
then: "$$ROOT",
else: "$$REMOVE"
}
}
},
checks: {
$push: {
$cond: {
if: { $eq: ["$changeType", "check"] },
then: "$$ROOT",
else: "$$REMOVE"
}
}
}
updates: { $push: "$$ROOT" },
}
},
{
Expand All @@ -63,17 +41,9 @@ export default [
{
$project: {
_id: 0,
id: 1,
type: 1,
lastModificationDate: 1,
siren: 1,
siret: 1,
id: "$_id",
paysageData: { $arrayElemAt: ["$paysageData", 0] },
updates: 1,
checks: 1,
}
},
{
$sort: { lastModificationDate: -1 }
}
];
4 changes: 2 additions & 2 deletions src/api/commons/repositories.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const geographicalCategoriesRepository = new BaseMongoRepository({
db,
collection: 'geographicalcategories',
});
export const geographicalCategoriesExceptionsRepository = new BaseMongoRepository({ db, collection: 'geographicalexceptions' });
export const geographicalCategoriesExceptionsRepository = new BaseMongoRepository({ db, collection: 'geographicalexceptions' });
export const groupsRepository = new BaseMongoRepository({
db,
collection: 'groups',
Expand Down Expand Up @@ -108,7 +108,7 @@ export const relationTypesRepository = new BaseMongoRepository({
});
export const sireneUpdatesRepository = new BaseMongoRepository({
db,
collection: '_siren',
collection: 'sirene_updates',
});
export const socialmediasRepository = new BaseMongoRepository({
db,
Expand Down

0 comments on commit faf86aa

Please sign in to comment.