feat: significantly improve global search

Fixes #713
This commit is contained in:
zkldi
2022-06-05 14:50:24 +01:00
parent a0af4b48d5
commit 647ca1409c
3 changed files with 88 additions and 3 deletions
+20
View File
@@ -265,3 +265,23 @@ export async function IsRequesterAdmin(request: APITokenDocument) {
return user.authLevel === UserAuthLevels.ADMIN;
}
/**
* Return all the GPTs this userID has played.
*/
export async function GetUserPlayedGPTs(userID: integer) {
const gpts = (await db["game-stats"].find(
{ userID },
{ projection: { game: 1, playtype: 1 } }
)) as Array<Pick<UserGameStats, "game" | "playtype">>;
return gpts;
}
export async function GetAllUserRivals(userID: integer) {
const rivals = (await db["game-settings"].find({ userID }, { projection: { rivals: 1 } }))
.map((e) => e.rivals)
.flat();
return rivals;
}