mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-09 00:45:32 +08:00
Add leaderboard avatars and badges (#3069) bruception
* Add leaderboard avatars and badges * Add discord id * badges -> badgeIds
This commit is contained in:
parent
d9da78673e
commit
b25ac99527
7 changed files with 29 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ export async function update(
|
|||
[str + ".uid"]: "$uid",
|
||||
[str + ".name"]: "$name",
|
||||
[str + ".discordId"]: "$discordId",
|
||||
[str + ".discordAvatar"]: "$discordAvatar",
|
||||
[str + ".badgeIds"]: "$badgeIds",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
1
backend/src/types/types.d.ts
vendored
1
backend/src/types/types.d.ts
vendored
|
|
@ -89,6 +89,7 @@ declare namespace MonkeyTypes {
|
|||
favoriteQuotes?: Record<string, string[]>;
|
||||
needsToChangeName?: boolean;
|
||||
discordAvatar?: string;
|
||||
badgeIds?: number[];
|
||||
}
|
||||
|
||||
type UserQuoteRatings = Record<string, Record<string, number>>;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ interface DailyLeaderboardEntry {
|
|||
timestamp: number;
|
||||
rank?: number;
|
||||
count?: number;
|
||||
discordAvatar?: string;
|
||||
discordId?: string;
|
||||
badgeIds?: number[];
|
||||
}
|
||||
|
||||
const dailyLeaderboardNamespace = "monkeytypes:dailyleaderboard";
|
||||
|
|
|
|||
4
frontend/src/ts/types/types.d.ts
vendored
4
frontend/src/ts/types/types.d.ts
vendored
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue