Add leaderboard avatars and badges (#3069) bruception

* Add leaderboard avatars and badges

* Add discord id

* badges -> badgeIds
This commit is contained in:
Bruce Berrios 2022-06-07 17:10:58 -04:00 committed by GitHub
parent d9da78673e
commit b25ac99527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 3 deletions

View file

@ -40,7 +40,7 @@ export async function getLeaderboard(
const normalizedLeaderboard = _.map(leaderboard, (entry) => {
return uid && entry.uid === uid
? entry
: _.omit(entry, ["discordId", "uid", "difficulty", "language"]);
: _.omit(entry, ["_id", "difficulty", "language"]);
});
return new MonkeyResponse("Leaderboard retrieved", normalizedLeaderboard);

View file

@ -335,6 +335,9 @@ export async function addResult(
consistency: result.consistency,
timestamp: result.timestamp,
uid,
discordAvatar: user.discordAvatar,
discordId: user.discordId,
badgeIds: user.badgeIds,
},
dailyLeaderboardsConfig
);

View file

@ -86,6 +86,8 @@ export async function update(
[str + ".uid"]: "$uid",
[str + ".name"]: "$name",
[str + ".discordId"]: "$discordId",
[str + ".discordAvatar"]: "$discordAvatar",
[str + ".badgeIds"]: "$badgeIds",
},
},
{

View file

@ -257,7 +257,7 @@
"LeaderboardEntry": {
"type": "object",
"properties": {
"_id": {
"uid": {
"type": "string",
"example": "6226b17aebc27a4a8d1ce04b"
},
@ -300,6 +300,21 @@
"timestamp": {
"type": "integer",
"example": 1644438189583
},
"discordId": {
"type": "string",
"example": "974761412044437307"
},
"discordAvatar": {
"type": "string",
"example": "6226b17aebc27a4a8d1ce04b"
},
"badgeIds": {
"type": "array",
"items": {
"type": "integer",
"example": 1
}
}
}
},

View file

@ -89,6 +89,7 @@ declare namespace MonkeyTypes {
favoriteQuotes?: Record<string, string[]>;
needsToChangeName?: boolean;
discordAvatar?: string;
badgeIds?: number[];
}
type UserQuoteRatings = Record<string, Record<string, number>>;

View file

@ -13,6 +13,9 @@ interface DailyLeaderboardEntry {
timestamp: number;
rank?: number;
count?: number;
discordAvatar?: string;
discordId?: string;
badgeIds?: number[];
}
const dailyLeaderboardNamespace = "monkeytypes:dailyleaderboard";

View file

@ -421,7 +421,7 @@ declare namespace MonkeyTypes {
}
interface LeaderboardEntry {
_id: string;
uid: string;
difficulty: string;
timestamp: number;
language: string;
@ -433,6 +433,8 @@ declare namespace MonkeyTypes {
uid?: string;
name: string;
discordId?: string;
discordAvatar?: string;
badgeIds?: number[];
rank: number;
count?: number;
hidden?: boolean;