rhythia-api 159.0.0 → 161.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.
package/api/approveMap.ts CHANGED
@@ -71,6 +71,7 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
71
71
  await supabase.from("beatmapPages").upsert({
72
72
  id: data.mapId,
73
73
  status: "RANKED",
74
+ ranked_at: Date.now(),
74
75
  });
75
76
 
76
77
  return NextResponse.json({});
@@ -16,6 +16,7 @@ export const Schema = {
16
16
  nominations: z.array(z.number()).nullable().optional(),
17
17
  playcount: z.number().nullable().optional(),
18
18
  created_at: z.string().nullable().optional(),
19
+ updated_at: z.number().nullable().optional(),
19
20
  difficulty: z.number().nullable().optional(),
20
21
  noteCount: z.number().nullable().optional(),
21
22
  length: z.number().nullable().optional(),
@@ -82,6 +83,7 @@ export async function handler(
82
83
  beatmap: {
83
84
  playcount: beatmapPage.beatmaps?.playcount,
84
85
  created_at: beatmapPage.created_at,
86
+ updated_at: beatmapPage.updated_at,
85
87
  difficulty: beatmapPage.beatmaps?.difficulty,
86
88
  noteCount: beatmapPage.beatmaps?.noteCount,
87
89
  length: beatmapPage.beatmaps?.length,
@@ -16,6 +16,7 @@ export const Schema = {
16
16
  nominations: z.array(z.number()).nullable().optional(),
17
17
  playcount: z.number().nullable().optional(),
18
18
  created_at: z.string().nullable().optional(),
19
+ updated_at: z.number().nullable().optional(),
19
20
  difficulty: z.number().nullable().optional(),
20
21
  noteCount: z.number().nullable().optional(),
21
22
  length: z.number().nullable().optional(),
@@ -78,6 +79,7 @@ export async function handler(
78
79
  beatmap: {
79
80
  playcount: beatmapPage.beatmaps?.playcount,
80
81
  created_at: beatmapPage.created_at,
82
+ updated_at: beatmapPage.updated_at,
81
83
  difficulty: beatmapPage.beatmaps?.difficulty,
82
84
  noteCount: beatmapPage.beatmaps?.noteCount,
83
85
  length: beatmapPage.beatmaps?.length,
@@ -9,6 +9,7 @@ export const Schema = {
9
9
  input: z.strictObject({
10
10
  session: z.string(),
11
11
  page: z.number().default(1),
12
+ flag: z.string().optional(),
12
13
  }),
13
14
  output: z.object({
14
15
  error: z.string().optional(),
@@ -43,13 +44,13 @@ export async function POST(request: Request): Promise<NextResponse> {
43
44
  export async function handler(
44
45
  data: (typeof Schema)["input"]["_type"]
45
46
  ): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
46
- const result = await getLeaderboard(data.page, data.session);
47
+ const result = await getLeaderboard(data.page, data.session, data.flag);
47
48
  return NextResponse.json(result);
48
49
  }
49
50
 
50
51
  const VIEW_PER_PAGE = 50;
51
52
 
52
- export async function getLeaderboard(page = 1, session: string) {
53
+ export async function getLeaderboard(page = 1, session: string, flag?: string) {
53
54
  const getUserData = (await getUserBySession(session)) as User;
54
55
 
55
56
  let leaderPosition = 0;
@@ -79,13 +80,16 @@ export async function getLeaderboard(page = 1, session: string) {
79
80
  .select("ban", { count: "exact", head: true })
80
81
  .neq("ban", "excluded");
81
82
 
82
- let { data: queryData, error } = await supabase
83
- .from("profiles")
84
- .select("*")
85
- .neq("ban", "excluded")
86
- .order("skill_points", { ascending: false })
87
- .range(startPage, endPage);
83
+ let query = supabase.from("profiles").select("*").neq("ban", "excluded");
84
+
85
+ if (flag) {
86
+ query.eq("flag", flag);
87
+ }
88
+
89
+ query.order("skill_points", { ascending: false });
90
+ query.range(startPage, endPage);
88
91
 
92
+ let { data: queryData, error } = await query;
89
93
  return {
90
94
  total: countQuery.count || 0,
91
95
  viewPerPage: VIEW_PER_PAGE,
@@ -91,7 +91,7 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
91
91
  `
92
92
  )
93
93
  .eq("status", "RANKED")
94
- .order("created_at", { ascending: false })
94
+ .order("ranked_at", { ascending: false })
95
95
  .limit(4);
96
96
 
97
97
  let { data: topUsers } = await supabase
package/api/getScore.ts CHANGED
@@ -25,6 +25,7 @@ export const Schema = {
25
25
  beatmapTitle: z.string().optional().nullable(),
26
26
  username: z.string().optional().nullable(),
27
27
  speed: z.number().optional().nullable(),
28
+ spin: z.boolean().optional().nullable(),
28
29
  })
29
30
  .optional(),
30
31
  }),
@@ -78,6 +79,7 @@ export async function handler(
78
79
  beatmapTitle: score.beatmaps?.title,
79
80
  username: score.profiles?.username,
80
81
  speed: score.speed,
82
+ spin: score.spin,
81
83
  },
82
84
  });
83
85
  }
@@ -25,6 +25,7 @@ export const Schema = {
25
25
  beatmapNotes: z.number().optional().nullable(),
26
26
  beatmapTitle: z.string().optional().nullable(),
27
27
  speed: z.number().optional().nullable(),
28
+ spin: z.boolean().optional().nullable(),
28
29
  })
29
30
  )
30
31
  .optional(),
@@ -44,6 +45,7 @@ export const Schema = {
44
45
  beatmapNotes: z.number().optional().nullable(),
45
46
  beatmapTitle: z.string().optional().nullable(),
46
47
  speed: z.number().optional().nullable(),
48
+ spin: z.boolean().optional().nullable(),
47
49
  })
48
50
  )
49
51
  .optional(),
@@ -131,6 +133,7 @@ export async function handler(
131
133
  beatmapNotes: s.beatmaps?.noteCount,
132
134
  beatmapTitle: s.beatmaps?.title,
133
135
  speed: s.speed,
136
+ spin: s.spin,
134
137
  })),
135
138
  top: vals?.map((s) => ({
136
139
  created_at: s.created_at,
@@ -146,6 +149,7 @@ export async function handler(
146
149
  beatmapNotes: s.beatmaps?.noteCount,
147
150
  beatmapTitle: s.beatmaps?.title,
148
151
  speed: s.speed,
152
+ spin: s.spin,
149
153
  })),
150
154
  });
151
155
  }
@@ -19,7 +19,8 @@ export const Schema = {
19
19
  mapHash: z.string(),
20
20
  speed: z.number(),
21
21
  mods: z.array(z.string()),
22
- additionalData: z.record(z.string(), z.any()),
22
+ additionalData: z.any(),
23
+ spin: z.boolean(),
23
24
  }),
24
25
  }),
25
26
  output: z.object({
@@ -37,11 +38,13 @@ export function calculatePerformancePoints(
37
38
  starRating: number,
38
39
  accuracy: number
39
40
  ) {
40
- return Math.round(
41
- Math.pow(
42
- (starRating * easeInExpoDeqHard(accuracy, starRating) * 100) / 2,
43
- 2
44
- ) / 1000
41
+ return (
42
+ Math.round(
43
+ Math.pow(
44
+ (starRating * easeInExpoDeqHard(accuracy, starRating) * 100) / 2,
45
+ 2
46
+ ) / 1000
47
+ ) * 2
45
48
  );
46
49
  }
47
50
 
@@ -71,6 +74,7 @@ export async function handler({
71
74
  speed: data.speed,
72
75
  mods: data.mods,
73
76
  additionalData: data.additionalData,
77
+ spin: data.spin,
74
78
  })
75
79
  ) {
76
80
  return NextResponse.json(
@@ -180,6 +184,12 @@ export async function handler({
180
184
  }
181
185
 
182
186
  console.log("p1");
187
+
188
+ let parsed = [];
189
+
190
+ try {
191
+ parsed = JSON.parse(decryptString(data.additionalData));
192
+ } catch (error) {}
183
193
  await supabase.from("scores").upsert({
184
194
  beatmapHash: data.mapHash,
185
195
  replayHwid: data.relayHwid,
@@ -190,6 +200,8 @@ export async function handler({
190
200
  awarded_sp: Math.round(awarded_sp * 100) / 100,
191
201
  speed: data.speed,
192
202
  mods: data.mods,
203
+ additional_data: parsed,
204
+ spin: data.spin || false,
193
205
  });
194
206
  console.log("p2");
195
207
 
@@ -74,6 +74,7 @@ export async function handler({
74
74
  owner: userData.id,
75
75
  description: description ? description : pageData.description,
76
76
  tags: tags ? tags : pageData.tags,
77
+ updated_at: Date.now(),
77
78
  };
78
79
 
79
80
  if (beatmapHash && beatmapData) {
package/index.ts CHANGED
@@ -191,6 +191,7 @@ export const Schema = {
191
191
  nominations: z.array(z.number()).nullable().optional(),
192
192
  playcount: z.number().nullable().optional(),
193
193
  created_at: z.string().nullable().optional(),
194
+ updated_at: z.number().nullable().optional(),
194
195
  difficulty: z.number().nullable().optional(),
195
196
  noteCount: z.number().nullable().optional(),
196
197
  length: z.number().nullable().optional(),
@@ -230,6 +231,7 @@ export const Schema = {
230
231
  nominations: z.array(z.number()).nullable().optional(),
231
232
  playcount: z.number().nullable().optional(),
232
233
  created_at: z.string().nullable().optional(),
234
+ updated_at: z.number().nullable().optional(),
233
235
  difficulty: z.number().nullable().optional(),
234
236
  noteCount: z.number().nullable().optional(),
235
237
  length: z.number().nullable().optional(),
@@ -328,6 +330,7 @@ export const Schema = {
328
330
  input: z.strictObject({
329
331
  session: z.string(),
330
332
  page: z.number().default(1),
333
+ flag: z.string().optional(),
331
334
  }),
332
335
  output: z.object({
333
336
  error: z.string().optional(),
@@ -507,6 +510,7 @@ export const Schema = {
507
510
  beatmapTitle: z.string().optional().nullable(),
508
511
  username: z.string().optional().nullable(),
509
512
  speed: z.number().optional().nullable(),
513
+ spin: z.boolean().optional().nullable(),
510
514
  })
511
515
  .optional(),
512
516
  }),
@@ -553,6 +557,7 @@ export const Schema = {
553
557
  beatmapNotes: z.number().optional().nullable(),
554
558
  beatmapTitle: z.string().optional().nullable(),
555
559
  speed: z.number().optional().nullable(),
560
+ spin: z.boolean().optional().nullable(),
556
561
  })
557
562
  )
558
563
  .optional(),
@@ -572,6 +577,7 @@ export const Schema = {
572
577
  beatmapNotes: z.number().optional().nullable(),
573
578
  beatmapTitle: z.string().optional().nullable(),
574
579
  speed: z.number().optional().nullable(),
580
+ spin: z.boolean().optional().nullable(),
575
581
  })
576
582
  )
577
583
  .optional(),
@@ -686,7 +692,8 @@ export const Schema = {
686
692
  mapHash: z.string(),
687
693
  speed: z.number(),
688
694
  mods: z.array(z.string()),
689
- additionalData: z.record(z.string(), z.any()),
695
+ additionalData: z.any(),
696
+ spin: z.boolean(),
690
697
  }),
691
698
  }),
692
699
  output: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "159.0.0",
3
+ "version": "161.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",
@@ -39,7 +39,7 @@
39
39
  "osu-standard-stable": "^5.0.0",
40
40
  "sharp": "^0.33.5",
41
41
  "simple-git": "^3.25.0",
42
- "supabase": "^2.0.0",
42
+ "supabase": "^2.1.1",
43
43
  "tsx": "^4.17.0",
44
44
  "utf-8-validate": "^6.0.4",
45
45
  "zod": "^3.23.8"
package/types/database.ts CHANGED
@@ -57,9 +57,11 @@ export type Database = {
57
57
  latestBeatmapHash: string | null
58
58
  nominations: Json | null
59
59
  owner: number | null
60
+ ranked_at: number
60
61
  status: string | null
61
62
  tags: string
62
63
  title: string | null
64
+ updated_at: number | null
63
65
  }
64
66
  Insert: {
65
67
  created_at?: string
@@ -69,9 +71,11 @@ export type Database = {
69
71
  latestBeatmapHash?: string | null
70
72
  nominations?: Json | null
71
73
  owner?: number | null
74
+ ranked_at?: number
72
75
  status?: string | null
73
76
  tags?: string
74
77
  title?: string | null
78
+ updated_at?: number | null
75
79
  }
76
80
  Update: {
77
81
  created_at?: string
@@ -81,9 +85,11 @@ export type Database = {
81
85
  latestBeatmapHash?: string | null
82
86
  nominations?: Json | null
83
87
  owner?: number | null
88
+ ranked_at?: number
84
89
  status?: string | null
85
90
  tags?: string
86
91
  title?: string | null
92
+ updated_at?: number | null
87
93
  }
88
94
  Relationships: [
89
95
  {
@@ -241,6 +247,7 @@ export type Database = {
241
247
  }
242
248
  scores: {
243
249
  Row: {
250
+ additional_data: Json
244
251
  awarded_sp: number | null
245
252
  beatmapHash: string | null
246
253
  created_at: string
@@ -251,9 +258,11 @@ export type Database = {
251
258
  replayHwid: string | null
252
259
  songId: string | null
253
260
  speed: number | null
261
+ spin: boolean
254
262
  userId: number | null
255
263
  }
256
264
  Insert: {
265
+ additional_data?: Json
257
266
  awarded_sp?: number | null
258
267
  beatmapHash?: string | null
259
268
  created_at?: string
@@ -264,9 +273,11 @@ export type Database = {
264
273
  replayHwid?: string | null
265
274
  songId?: string | null
266
275
  speed?: number | null
276
+ spin?: boolean
267
277
  userId?: number | null
268
278
  }
269
279
  Update: {
280
+ additional_data?: Json
270
281
  awarded_sp?: number | null
271
282
  beatmapHash?: string | null
272
283
  created_at?: string
@@ -277,6 +288,7 @@ export type Database = {
277
288
  replayHwid?: string | null
278
289
  songId?: string | null
279
290
  speed?: number | null
291
+ spin?: boolean
280
292
  userId?: number | null
281
293
  }
282
294
  Relationships: [