rhythia-api 180.0.0 → 181.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/getCollections.ts +27 -2
- package/index.ts +3 -0
- package/package.json +1 -1
- package/types/database.ts +44 -0
package/api/getCollections.ts
CHANGED
|
@@ -15,6 +15,9 @@ export const Schema = {
|
|
|
15
15
|
id: z.number(),
|
|
16
16
|
title: z.string(),
|
|
17
17
|
description: z.string(),
|
|
18
|
+
owner: z.number(),
|
|
19
|
+
ownerUsername: z.string(),
|
|
20
|
+
ownerAvatarUrl: z.string(),
|
|
18
21
|
beatmapCount: z.number(),
|
|
19
22
|
starRatingDistribution: z.array(
|
|
20
23
|
z.object({
|
|
@@ -41,7 +44,7 @@ export async function POST(request: Request) {
|
|
|
41
44
|
|
|
42
45
|
export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
43
46
|
const { data: collections, error } = await supabase
|
|
44
|
-
.rpc("
|
|
47
|
+
.rpc("get_collections_v2", {
|
|
45
48
|
page_number: data.page,
|
|
46
49
|
items_per_page: data.itemsPerPage,
|
|
47
50
|
})
|
|
@@ -51,6 +54,9 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
51
54
|
title: string;
|
|
52
55
|
description: string;
|
|
53
56
|
created_at: string;
|
|
57
|
+
owner: number;
|
|
58
|
+
owner_username: string;
|
|
59
|
+
owner_avatar_url: string;
|
|
54
60
|
beatmap_count: number;
|
|
55
61
|
star1: number;
|
|
56
62
|
star2: number;
|
|
@@ -62,12 +68,20 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
62
68
|
star8: number;
|
|
63
69
|
star9: number;
|
|
64
70
|
star10: number;
|
|
71
|
+
star11: number;
|
|
72
|
+
star12: number;
|
|
73
|
+
star13: number;
|
|
74
|
+
star14: number;
|
|
75
|
+
star15: number;
|
|
76
|
+
star16: number;
|
|
77
|
+
star17: number;
|
|
78
|
+
star18: number;
|
|
65
79
|
total_pages: number;
|
|
66
80
|
}[]
|
|
67
81
|
>();
|
|
68
82
|
|
|
69
83
|
if (error) {
|
|
70
|
-
return NextResponse.json({ error
|
|
84
|
+
return NextResponse.json({ error });
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
// Get the total pages from the first row (all rows will have the same value)
|
|
@@ -78,6 +92,9 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
78
92
|
id: collection.id,
|
|
79
93
|
title: collection.title,
|
|
80
94
|
description: collection.description,
|
|
95
|
+
owner: collection.owner,
|
|
96
|
+
ownerUsername: collection.owner_username,
|
|
97
|
+
ownerAvatarUrl: collection.owner_avatar_url,
|
|
81
98
|
beatmapCount: collection.beatmap_count,
|
|
82
99
|
starRatingDistribution: [
|
|
83
100
|
{ stars: 1, count: collection.star1 },
|
|
@@ -90,6 +107,14 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
90
107
|
{ stars: 8, count: collection.star8 },
|
|
91
108
|
{ stars: 9, count: collection.star9 },
|
|
92
109
|
{ stars: 10, count: collection.star10 },
|
|
110
|
+
{ stars: 11, count: collection.star11 },
|
|
111
|
+
{ stars: 12, count: collection.star12 },
|
|
112
|
+
{ stars: 13, count: collection.star13 },
|
|
113
|
+
{ stars: 14, count: collection.star14 },
|
|
114
|
+
{ stars: 15, count: collection.star15 },
|
|
115
|
+
{ stars: 16, count: collection.star16 },
|
|
116
|
+
{ stars: 17, count: collection.star17 },
|
|
117
|
+
{ stars: 18, count: collection.star18 },
|
|
93
118
|
],
|
|
94
119
|
createdAt: collection.created_at,
|
|
95
120
|
})) || [];
|
package/index.ts
CHANGED
|
@@ -556,6 +556,9 @@ export const Schema = {
|
|
|
556
556
|
id: z.number(),
|
|
557
557
|
title: z.string(),
|
|
558
558
|
description: z.string(),
|
|
559
|
+
owner: z.number(),
|
|
560
|
+
ownerUsername: z.string(),
|
|
561
|
+
ownerAvatarUrl: z.string(),
|
|
559
562
|
beatmapCount: z.number(),
|
|
560
563
|
starRatingDistribution: z.array(
|
|
561
564
|
z.object({
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -515,6 +515,42 @@ export type Database = {
|
|
|
515
515
|
title: string
|
|
516
516
|
description: string
|
|
517
517
|
created_at: string
|
|
518
|
+
owner: number
|
|
519
|
+
beatmap_count: number
|
|
520
|
+
star1: number
|
|
521
|
+
star2: number
|
|
522
|
+
star3: number
|
|
523
|
+
star4: number
|
|
524
|
+
star5: number
|
|
525
|
+
star6: number
|
|
526
|
+
star7: number
|
|
527
|
+
star8: number
|
|
528
|
+
star9: number
|
|
529
|
+
star10: number
|
|
530
|
+
star11: number
|
|
531
|
+
star12: number
|
|
532
|
+
star13: number
|
|
533
|
+
star14: number
|
|
534
|
+
star15: number
|
|
535
|
+
star16: number
|
|
536
|
+
star17: number
|
|
537
|
+
star18: number
|
|
538
|
+
total_pages: number
|
|
539
|
+
}[]
|
|
540
|
+
}
|
|
541
|
+
get_collections_v2: {
|
|
542
|
+
Args: {
|
|
543
|
+
page_number?: number
|
|
544
|
+
items_per_page?: number
|
|
545
|
+
}
|
|
546
|
+
Returns: {
|
|
547
|
+
id: number
|
|
548
|
+
title: string
|
|
549
|
+
description: string
|
|
550
|
+
created_at: string
|
|
551
|
+
owner: number
|
|
552
|
+
owner_username: string
|
|
553
|
+
owner_avatar_url: string
|
|
518
554
|
beatmap_count: number
|
|
519
555
|
star1: number
|
|
520
556
|
star2: number
|
|
@@ -526,6 +562,14 @@ export type Database = {
|
|
|
526
562
|
star8: number
|
|
527
563
|
star9: number
|
|
528
564
|
star10: number
|
|
565
|
+
star11: number
|
|
566
|
+
star12: number
|
|
567
|
+
star13: number
|
|
568
|
+
star14: number
|
|
569
|
+
star15: number
|
|
570
|
+
star16: number
|
|
571
|
+
star17: number
|
|
572
|
+
star18: number
|
|
529
573
|
total_pages: number
|
|
530
574
|
}[]
|
|
531
575
|
}
|