mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: fix stats handle for non-integer score
This commit is contained in:
1 parent
7b112817c6
commit
a648d51969
4 files changed
+13
-4
No files matched your search
@@ -105,7 +105,16 @@ export async function pdoc(report) {
|
||||
},
|
||||
];
|
||||
for (let i = 0; i <= 100; i++) {
|
||||
pipeline[1].$group[`s${i}`] = { $sum: { $cond: [{ $eq: ['$score', i] }, 1, 0] } };
|
||||
pipeline[1].$group[`s${i}`] = {
|
||||
$sum: {
|
||||
$cond: [{
|
||||
$and: [
|
||||
{ $gte: ['$score', i] },
|
||||
{ $lt: ['$score', i + 1] },
|
||||
],
|
||||
}, 1, 0],
|
||||
},
|
||||
};
|
||||
pipeline[2].$group[`s${i}`] = { $sum: `$s${i}` };
|
||||
}
|
||||
let bulk = db.collection('document').initializeUnorderedBulkOp();
|
||||
|
||||
Reference in new issue
Block a user