mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add getRelatedUsers
This commit is contained in:
1 parent
fc251d1124
commit
915c01f703
2 files changed
+13
-2
No files matched your search
@@ -84,13 +84,14 @@ async function runContest(...arg: any[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function calcLevel(domainId: string, report: Function) {
|
export async function calcLevel(domainId: string, report: Function) {
|
||||||
const ducnt = await domain.getMultiUserInDomain(domainId).count();
|
const filter = { rp: { $ne: 1500, $exists: true } };
|
||||||
|
const ducnt = await domain.getMultiUserInDomain(domainId, filter).count();
|
||||||
if (!ducnt) return;
|
if (!ducnt) return;
|
||||||
let last = { rp: null };
|
let last = { rp: null };
|
||||||
let rank = 0;
|
let rank = 0;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const coll = global.Hydro.service.db.collection('domain.user');
|
const coll = global.Hydro.service.db.collection('domain.user');
|
||||||
const ducur = domain.getMultiUserInDomain(domainId).project({ rp: 1 }).sort({ rp: -1 });
|
const ducur = domain.getMultiUserInDomain(domainId, filter).project({ rp: 1 }).sort({ rp: -1 });
|
||||||
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();
|
||||||
|
|||||||
@@ -32,4 +32,14 @@ export function logAndReturn(logger: Logger) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RE_USER = /(?:^|\s)(@)([^ ]{3,255}?)(?=\s|$)/g;
|
||||||
|
|
||||||
|
export function getRelatedUsers(content: string) {
|
||||||
|
const results = [];
|
||||||
|
let res: string[];
|
||||||
|
// eslint-disable-next-line no-cond-assign
|
||||||
|
while (res = RE_USER.exec(content)) results.push(res[2]);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
export * from '@hydrooj/utils/lib/utils';
|
export * from '@hydrooj/utils/lib/utils';
|
||||||
Reference in new issue
Block a user