Skip to content

Commit

Permalink
fix: tri des transmissions par nombre d'erreur décroissant
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomarom committed Mar 15, 2024
1 parent f6d1977 commit a78d8d9
Showing 1 changed file with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,6 @@ export const getAllErrorsTransmissionStatusGroupedByOrganismeForAGivenDay = asyn
$gte: start,
$lte: end,
},
validation_errors: {
$exists: true,
},
},
},
{
Expand All @@ -606,33 +603,45 @@ export const getAllErrorsTransmissionStatusGroupedByOrganismeForAGivenDay = asyn
},
},
},
{
$lookup: {
from: "organismes",
localField: "source_organisme_id",
foreignField: "_id",
as: "source_organisme",
},
},
{
$unwind: "$source_organisme",
},
{
$project: {
_id: 0,
"organisme.nom": "$source_organisme.nom",
"organisme.id": "$source_organisme._id",
"organisme.uai": "$source_organisme.uai",
"organisme.siret": "$source_organisme.siret",
success: "$success",
error: "$error",
total: "$total",
},
},
{
$facet: {
pagination: [{ $count: "total" }, { $addFields: { page, limit } }],
data: [{ $skip: (page - 1) * limit }, { $limit: limit }],
data: [
{ $sort: { error: -1 } },
{ $skip: (page - 1) * limit },
{ $limit: limit },
{
$lookup: {
from: "organismes",
localField: "source_organisme_id",
foreignField: "_id",
as: "source_organisme",
},
},
{
$unwind: "$source_organisme",
},
{
$project: {
_id: 0,
"organisme.nom": "$source_organisme.nom",
"organisme.id": "$source_organisme._id",
"organisme.uai": "$source_organisme.uai",
"organisme.siret": "$source_organisme.siret",
success: "$success",
error: "$error",
total: "$total",
successRate: {
$multiply: [
{
$divide: ["$success", "$total"],
},
100,
],
},
},
},
],
},
},
{ $unwind: { path: "$pagination" } },
Expand Down

0 comments on commit a78d8d9

Please sign in to comment.