core: 计算ranking时忽略Hydro用户

This commit is contained in:
undefined committed 2021-06-13 11:57:00 +08:00
1 parent 382dd53c0c
commit 923d10fb84
4 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.28.33", "version": "2.28.34",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+1 -1
View File
@@ -24,7 +24,7 @@ class DomainRankHandler extends Handler {
@query('page', Types.PositiveInt, true) @query('page', Types.PositiveInt, true)
async get(domainId: string, page = 1) { async get(domainId: string, page = 1) {
const [dudocs, upcount, ucount] = await paginate( const [dudocs, upcount, ucount] = await paginate(
domain.getMultiUserInDomain(domainId).sort({ rp: -1 }), domain.getMultiUserInDomain(domainId, { uid: { $nin: [0, 1] } }).sort({ rp: -1 }),
page, page,
100, 100,
); );
+1 -1
View File
@@ -87,7 +87,7 @@ class HomeHandler extends Handler {
async getRanking(domainId: string, limit: number = 50) { async getRanking(domainId: string, limit: number = 50) {
if (this.user.hasPerm(PERM.PERM_VIEW_RANKING)) { if (this.user.hasPerm(PERM.PERM_VIEW_RANKING)) {
const dudocs = await domain.getMultiUserInDomain(domainId) const dudocs = await domain.getMultiUserInDomain(domainId, { uid: { $nin: [0, 1] } })
.sort({ rp: -1 }).project({ uid: 1 }).limit(limit).toArray(); .sort({ rp: -1 }).project({ uid: 1 }).limit(limit).toArray();
const uids = dudocs.map((dudoc) => dudoc.uid); const uids = dudocs.map((dudoc) => dudoc.uid);
this.collectUser(uids); this.collectUser(uids);
+1
View File
@@ -95,6 +95,7 @@ export async function calcLevel(domainId: string, report: Function) {
let bulk = coll.initializeUnorderedBulkOp(); let bulk = coll.initializeUnorderedBulkOp();
while (await ducur.hasNext()) { while (await ducur.hasNext()) {
const dudoc = await ducur.next(); const dudoc = await ducur.next();
if ([0, 1].includes(dudoc.uid)) continue;
count++; count++;
if (!dudoc.rp) dudoc.rp = null; if (!dudoc.rp) dudoc.rp = null;
if (dudoc.rp !== last.rp) rank = count; if (dudoc.rp !== last.rp) rank = count;