rhythia-api 189.0.0 → 191.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.
@@ -10,6 +10,24 @@ export const Schema = {
10
10
  }),
11
11
  output: z.object({
12
12
  error: z.string().optional(),
13
+ scores: z
14
+ .array(
15
+ z.object({
16
+ id: z.number(),
17
+ awarded_sp: z.number().nullable(),
18
+ created_at: z.string(), // Assuming Supabase returns timestamps as strings
19
+ misses: z.number().nullable(),
20
+ mods: z.record(z.unknown()), // JSONB data, can be any object
21
+ passed: z.boolean().nullable(),
22
+ songId: z.string().nullable(),
23
+ speed: z.number().nullable(),
24
+ spin: z.boolean(),
25
+ userId: z.number().nullable(),
26
+ username: z.string().nullable(),
27
+ avatar_url: z.string().nullable(),
28
+ })
29
+ )
30
+ .optional(),
13
31
  beatmap: z
14
32
  .object({
15
33
  id: z.number().nullable().optional(),
@@ -77,9 +95,32 @@ export async function handler(
77
95
  .eq("id", data.id)
78
96
  .single();
79
97
 
98
+ const { data: scoreData, error } = await supabase.rpc(
99
+ "get_top_scores_for_beatmap",
100
+ { beatmap_hash: beatmapPage?.latestBeatmapHash || "" }
101
+ );
102
+
103
+ if (error) {
104
+ return NextResponse.json({ error: JSON.stringify(error) });
105
+ }
106
+
80
107
  if (!beatmapPage) return NextResponse.json({});
81
108
 
82
109
  return NextResponse.json({
110
+ scores: scoreData.map((score: any) => ({
111
+ id: score.id,
112
+ awarded_sp: score.awarded_sp,
113
+ created_at: score.created_at,
114
+ misses: score.misses,
115
+ mods: score.mods,
116
+ passed: score.passed,
117
+ songId: score.songid,
118
+ speed: score.speed,
119
+ spin: score.spin,
120
+ userId: score.userid,
121
+ username: score.username,
122
+ avatar_url: score.avatar_url,
123
+ })),
83
124
  beatmap: {
84
125
  playcount: beatmapPage.beatmaps?.playcount,
85
126
  created_at: beatmapPage.created_at,
@@ -10,6 +10,24 @@ export const Schema = {
10
10
  }),
11
11
  output: z.object({
12
12
  error: z.string().optional(),
13
+ scores: z
14
+ .array(
15
+ z.object({
16
+ id: z.number(),
17
+ awarded_sp: z.number().nullable(),
18
+ created_at: z.string(), // Assuming Supabase returns timestamps as strings
19
+ misses: z.number().nullable(),
20
+ mods: z.record(z.unknown()), // JSONB data, can be any object
21
+ passed: z.boolean().nullable(),
22
+ songId: z.string().nullable(),
23
+ speed: z.number().nullable(),
24
+ spin: z.boolean(),
25
+ userId: z.number().nullable(),
26
+ username: z.string().nullable(),
27
+ avatar_url: z.string().nullable(),
28
+ })
29
+ )
30
+ .optional(),
13
31
  beatmap: z
14
32
  .object({
15
33
  id: z.number().nullable().optional(),
@@ -75,7 +93,30 @@ export async function handler(
75
93
 
76
94
  if (!beatmapPage) return NextResponse.json({});
77
95
 
96
+ const { data: scoreData, error } = await supabase.rpc(
97
+ "get_top_scores_for_beatmap",
98
+ { beatmap_hash: beatmapPage?.latestBeatmapHash || "" }
99
+ );
100
+
101
+ if (error) {
102
+ return NextResponse.json({ error: JSON.stringify(error) });
103
+ }
104
+
78
105
  return NextResponse.json({
106
+ scores: scoreData.map((score: any) => ({
107
+ id: score.id,
108
+ awarded_sp: score.awarded_sp,
109
+ created_at: score.created_at,
110
+ misses: score.misses,
111
+ mods: score.mods,
112
+ passed: score.passed,
113
+ songId: score.songid,
114
+ speed: score.speed,
115
+ spin: score.spin,
116
+ userId: score.userid,
117
+ username: score.username,
118
+ avatar_url: score.avatar_url,
119
+ })),
79
120
  beatmap: {
80
121
  playcount: beatmapPage.beatmaps?.playcount,
81
122
  created_at: beatmapPage.created_at,
package/api/getClan.ts CHANGED
@@ -62,7 +62,8 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
62
62
  let { data: queryUsers, error: usersError } = await supabase
63
63
  .from("profiles")
64
64
  .select("*")
65
- .eq("clan", queryClanData.id);
65
+ .eq("clan", queryClanData.id)
66
+ .neq("ban", "excluded");
66
67
 
67
68
  return NextResponse.json({
68
69
  acronym: queryClanData.acronym,
@@ -30,6 +30,22 @@ export const Schema = {
30
30
  })
31
31
  )
32
32
  .optional(),
33
+ reign: z
34
+ .array(
35
+ z.object({
36
+ id: z.number(), // Use z.number() for compatibility, or z.bigint() if supported
37
+ awarded_sp: z.number().nullable(), // Use z.number() for NUMERIC
38
+ created_at: z.string(), // Use z.string() for TIMESTAMP WITH TIME ZONE
39
+ misses: z.number().nullable(),
40
+ mods: z.record(z.unknown()),
41
+ passed: z.boolean().nullable(),
42
+ songId: z.string().nullable(),
43
+ speed: z.number().nullable(),
44
+ spin: z.boolean(),
45
+ beatmapHash: z.string().nullable(), // Add beatmapHash to the schema
46
+ })
47
+ )
48
+ .optional(),
33
49
  top: z
34
50
  .array(
35
51
  z.object({
@@ -135,6 +151,15 @@ export async function handler(
135
151
  .slice(0, data.limit)
136
152
  .map((e) => e.score);
137
153
 
154
+ const { data: reignScores, error } = await supabase.rpc(
155
+ "get_user_reigning_scores",
156
+ { userid: data.id }
157
+ );
158
+
159
+ if (error) {
160
+ return NextResponse.json({ error: JSON.stringify(error) });
161
+ }
162
+
138
163
  return NextResponse.json({
139
164
  lastDay: scores1?.map((s) => ({
140
165
  created_at: s.created_at,
@@ -151,6 +176,18 @@ export async function handler(
151
176
  speed: s.speed,
152
177
  spin: s.spin,
153
178
  })),
179
+ reign: reignScores?.map((s) => ({
180
+ id: s.id,
181
+ awarded_sp: s.awarded_sp,
182
+ created_at: s.created_at,
183
+ misses: s.misses,
184
+ mods: s.mods as any,
185
+ passed: s.passed,
186
+ songId: s.songid,
187
+ speed: s.speed,
188
+ spin: s.spin,
189
+ beatmapHash: s.beatmaphash,
190
+ })),
154
191
  top: vals?.map((s) => ({
155
192
  created_at: s.created_at,
156
193
  id: s.id,
package/index.ts CHANGED
@@ -344,6 +344,24 @@ export const Schema = {
344
344
  }),
345
345
  output: z.object({
346
346
  error: z.string().optional(),
347
+ scores: z
348
+ .array(
349
+ z.object({
350
+ id: z.number(),
351
+ awarded_sp: z.number().nullable(),
352
+ created_at: z.string(), // Assuming Supabase returns timestamps as strings
353
+ misses: z.number().nullable(),
354
+ mods: z.record(z.unknown()), // JSONB data, can be any object
355
+ passed: z.boolean().nullable(),
356
+ songId: z.string().nullable(),
357
+ speed: z.number().nullable(),
358
+ spin: z.boolean(),
359
+ userId: z.number().nullable(),
360
+ username: z.string().nullable(),
361
+ avatar_url: z.string().nullable(),
362
+ })
363
+ )
364
+ .optional(),
347
365
  beatmap: z
348
366
  .object({
349
367
  id: z.number().nullable().optional(),
@@ -384,6 +402,24 @@ export const Schema = {
384
402
  }),
385
403
  output: z.object({
386
404
  error: z.string().optional(),
405
+ scores: z
406
+ .array(
407
+ z.object({
408
+ id: z.number(),
409
+ awarded_sp: z.number().nullable(),
410
+ created_at: z.string(), // Assuming Supabase returns timestamps as strings
411
+ misses: z.number().nullable(),
412
+ mods: z.record(z.unknown()), // JSONB data, can be any object
413
+ passed: z.boolean().nullable(),
414
+ songId: z.string().nullable(),
415
+ speed: z.number().nullable(),
416
+ spin: z.boolean(),
417
+ userId: z.number().nullable(),
418
+ username: z.string().nullable(),
419
+ avatar_url: z.string().nullable(),
420
+ })
421
+ )
422
+ .optional(),
387
423
  beatmap: z
388
424
  .object({
389
425
  id: z.number().nullable().optional(),
@@ -918,6 +954,22 @@ export const Schema = {
918
954
  })
919
955
  )
920
956
  .optional(),
957
+ reign: z
958
+ .array(
959
+ z.object({
960
+ id: z.number(), // Use z.number() for compatibility, or z.bigint() if supported
961
+ awarded_sp: z.number().nullable(), // Use z.number() for NUMERIC
962
+ created_at: z.string(), // Use z.string() for TIMESTAMP WITH TIME ZONE
963
+ misses: z.number().nullable(),
964
+ mods: z.record(z.unknown()),
965
+ passed: z.boolean().nullable(),
966
+ songId: z.string().nullable(),
967
+ speed: z.number().nullable(),
968
+ spin: z.boolean(),
969
+ beatmapHash: z.string().nullable(), // Add beatmapHash to the schema
970
+ })
971
+ )
972
+ .optional(),
921
973
  top: z
922
974
  .array(
923
975
  z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "189.0.0",
3
+ "version": "191.0.0",
4
4
  "main": "index.ts",
5
5
  "author": "online-contributors",
6
6
  "scripts": {
package/types/database.ts CHANGED
@@ -734,6 +734,44 @@ export type Database = {
734
734
  total_pages: number
735
735
  }[]
736
736
  }
737
+ get_top_scores_for_beatmap: {
738
+ Args: {
739
+ beatmap_hash: string
740
+ }
741
+ Returns: {
742
+ id: number
743
+ awarded_sp: number
744
+ created_at: string
745
+ misses: number
746
+ mods: Json
747
+ passed: boolean
748
+ replayhwid: string
749
+ songid: string
750
+ speed: number
751
+ spin: boolean
752
+ userid: number
753
+ username: string
754
+ avatar_url: string
755
+ }[]
756
+ }
757
+ get_user_reigning_scores: {
758
+ Args: {
759
+ userid: number
760
+ }
761
+ Returns: {
762
+ id: number
763
+ awarded_sp: number
764
+ created_at: string
765
+ misses: number
766
+ mods: Json
767
+ passed: boolean
768
+ replayhwid: string
769
+ songid: string
770
+ speed: number
771
+ spin: boolean
772
+ beatmaphash: string
773
+ }[]
774
+ }
737
775
  }
738
776
  Enums: {
739
777
  banTypes: "cool" | "silenced" | "restricted" | "excluded"