rhythia-api 205.0.0 → 207.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(yarn update)"
5
+ ],
6
+ "deny": []
7
+ }
8
+ }
@@ -19,6 +19,12 @@ const adminOperations = {
19
19
  removeAllScores: z.object({ userId: z.number() }),
20
20
  invalidateRankedScores: z.object({ userId: z.number() }),
21
21
  unbanUser: z.object({ userId: z.number() }),
22
+ getScoresPaginated: z.object({
23
+ page: z.number().min(1).default(1),
24
+ limit: z.number().min(1).max(100).default(50),
25
+ userId: z.number().optional(),
26
+ includeAdditionalData: z.boolean().default(true),
27
+ }),
22
28
  } as const;
23
29
 
24
30
  // Create a discriminated union type for operation parameters
@@ -67,6 +73,10 @@ const OperationParam = z.discriminatedUnion("operation", [
67
73
  operation: z.literal("changeBadges"),
68
74
  params: adminOperations.changeBadges,
69
75
  }),
76
+ z.object({
77
+ operation: z.literal("getScoresPaginated"),
78
+ params: adminOperations.getScoresPaginated,
79
+ }),
70
80
  ]);
71
81
 
72
82
  export const Schema = {
@@ -209,6 +219,103 @@ export async function handler(
209
219
  }
210
220
 
211
221
  break;
222
+
223
+ case "getScoresPaginated":
224
+ const offset = (params.page - 1) * params.limit;
225
+ let query = supabase
226
+ .from("scores")
227
+ .select(
228
+ `
229
+ id,
230
+ awarded_sp,
231
+ created_at,
232
+ misses,
233
+ mods,
234
+ passed,
235
+ songId,
236
+ speed,
237
+ spin,
238
+ userId,
239
+ beatmapHash,
240
+ additional_data,
241
+ beatmaps (
242
+ difficulty,
243
+ noteCount,
244
+ title,
245
+ starRating,
246
+ image,
247
+ imageLarge
248
+ ),
249
+ profiles (
250
+ username,
251
+ avatar_url
252
+ )
253
+ `
254
+ )
255
+ .order("created_at", { ascending: false })
256
+ .range(offset, offset + params.limit - 1);
257
+
258
+ if (params.userId) {
259
+ query = query.eq("userId", params.userId);
260
+ }
261
+
262
+ const { data: scoresData, error: scoresError, count } = await query;
263
+
264
+ if (scoresError) {
265
+ result = { error: scoresError, data: null };
266
+ } else {
267
+ const transformedScores = scoresData?.map((score) => {
268
+ const transformed: any = {
269
+ id: score.id,
270
+ awarded_sp: score.awarded_sp,
271
+ created_at: score.created_at,
272
+ misses: score.misses,
273
+ mods: score.mods,
274
+ passed: score.passed,
275
+ songId: score.songId,
276
+ speed: score.speed,
277
+ spin: score.spin,
278
+ userId: score.userId,
279
+ beatmapHash: score.beatmapHash,
280
+ beatmap: score.beatmaps
281
+ ? {
282
+ difficulty: score.beatmaps.difficulty,
283
+ noteCount: score.beatmaps.noteCount,
284
+ title: score.beatmaps.title,
285
+ starRating: score.beatmaps.starRating,
286
+ image: score.beatmaps.image,
287
+ imageLarge: score.beatmaps.imageLarge,
288
+ }
289
+ : null,
290
+ profile: score.profiles
291
+ ? {
292
+ username: score.profiles.username,
293
+ avatar_url: score.profiles.avatar_url,
294
+ }
295
+ : null,
296
+ };
297
+
298
+ if (params.includeAdditionalData) {
299
+ transformed.additional_data = score.additional_data;
300
+ }
301
+
302
+ return transformed;
303
+ });
304
+
305
+ result = {
306
+ data: {
307
+ scores: transformedScores,
308
+ pagination: {
309
+ page: params.page,
310
+ limit: params.limit,
311
+ total: count || 0,
312
+ totalPages: Math.ceil((count || 0) / params.limit),
313
+ },
314
+ },
315
+ error: null,
316
+ };
317
+ }
318
+ break;
212
319
  }
213
320
 
214
321
  // Log the admin action
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "205.0.0",
3
+ "version": "207.0.0",
4
4
  "main": "index.ts",
5
5
  "author": "online-contributors-cunev",
6
6
  "scripts": {