MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / getListForRender

Method getListForRender

packages/hydrooj/src/model/user.ts:412–438  ·  view source on GitHub ↗
(domainId: string, uids: number[], arg: string[] | boolean, extraFields?: string[])

Source from the content-addressed store, hash-verified

410 static async getListForRender(domainId: string, uids: number[], showPrivateInfo: boolean, extraFields?: string[]): Promise<BaseUserDict>;
411 static async getListForRender(domainId: string, uids: number[], extraFields?: string[]): Promise<BaseUserDict>;
412 static async getListForRender(domainId: string, uids: number[], arg: string[] | boolean, extraFields?: string[]) {
413 const _extraFields = Array.isArray(arg) ? arg : Array.isArray(extraFields) ? extraFields : [];
414 const showPrivateInfo = arg === true || _extraFields.includes('displayName');
415 const fields = Array.from(new Set([
416 ...(await UserModel.getById('system', 0)).getFields(showPrivateInfo ? 'private' : 'public'),
417 ..._extraFields,
418 ]));
419 const [udocs, vudocs, dudocs] = await Promise.all([
420 UserModel.getMulti({ _id: { $in: uids } }, fields).toArray(),
421 collV.find({ _id: { $in: uids } }).toArray(),
422 domain.getDomainUserMulti(domainId, uids).project(buildProjection(fields.concat('uid'))).toArray(),
423 ]);
424 const udict = {};
425 for (const udoc of udocs) udict[udoc._id] = udoc;
426 for (const udoc of vudocs) udict[udoc._id] = udoc;
427 if (showPrivateInfo) {
428 for (const dudoc of dudocs) Object.assign(udict[dudoc.uid], omit(dudoc, ['_id', 'uid']));
429 }
430 for (const uid of uids) udict[uid] ||= { ...UserModel.defaultUser };
431 for (const key in udict) {
432 udict[key].school ||= '';
433 udict[key].studentId ||= '';
434 udict[key].displayName ||= udict[key].uname;
435 udict[key].avatar ||= `gravatar:${udict[key].mail}`;
436 }
437 return udict as BaseUserDict;
438 }
439
440 @ArgMethod
441 static async getPrefixList(domainId: string, prefix: string, limit: number = 50) {

Callers 7

scoreboardFunction · 0.80
getMethod · 0.80
getMethod · 0.80
postGetPrintTaskMethod · 0.80
getMethod · 0.80
getMethod · 0.80
getMethod · 0.80

Calls 7

buildProjectionFunction · 0.90
getFieldsMethod · 0.80
getByIdMethod · 0.80
findMethod · 0.80
getDomainUserMultiMethod · 0.80
allMethod · 0.45
getMultiMethod · 0.45

Tested by

no test coverage detected