@@ -109,7 +109,7 @@ export class WeeklyXpLeaderboard {
109109 entry . uid ,
110110 xpGained ,
111111 JSON . stringify ( { ...entry , timeTypedSeconds : totalTimeTypedSeconds } )
112- ) ,
112+ ) as Promise < number > ,
113113 LaterQueue . scheduleForNextWeek (
114114 "weekly-xp-leaderboard-results" ,
115115 "weekly-xp"
@@ -155,11 +155,16 @@ export class WeeklyXpLeaderboard {
155155 }
156156
157157 const resultsWithRanks : WeeklyXpLeaderboardEntry [ ] = results . map (
158- ( resultJSON : string , index : number ) => ( {
159- ...JSON . parse ( resultJSON ) ,
160- rank : minRank + index + 1 ,
161- totalXp : parseInt ( scores [ index ] as string , 10 ) ,
162- } )
158+ ( resultJSON : string , index : number ) => {
159+ //TODO parse with zod?
160+ const parsed = JSON . parse ( resultJSON ) as WeeklyXpLeaderboardEntry ;
161+
162+ return {
163+ ...parsed ,
164+ rank : minRank + index + 1 ,
165+ totalXp : parseInt ( scores [ index ] as string , 10 ) ,
166+ } ;
167+ }
163168 ) ;
164169
165170 return resultsWithRanks ;
@@ -193,11 +198,17 @@ export class WeeklyXpLeaderboard {
193198 return null ;
194199 }
195200
201+ //TODO parse with zod?
202+ const parsed = JSON . parse ( result ?? "null" ) as Omit <
203+ WeeklyXpLeaderboardEntry ,
204+ "rank" | "count" | "totalXp"
205+ > ;
206+
196207 return {
197208 rank : rank + 1 ,
198209 count : count ?? 0 ,
199210 totalXp : parseInt ( totalXp , 10 ) ,
200- ...JSON . parse ( result ?? "null" ) ,
211+ ...parsed ,
201212 } ;
202213 }
203214}
0 commit comments