rhythia-api 153.0.0 → 154.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/getPublicStats.ts +65 -0
- package/api/submitScore.ts +10 -5
- package/index.ts +20 -0
- package/package.json +1 -1
package/api/getPublicStats.ts
CHANGED
|
@@ -9,6 +9,26 @@ export const Schema = {
|
|
|
9
9
|
profiles: z.number(),
|
|
10
10
|
beatmaps: z.number(),
|
|
11
11
|
scores: z.number(),
|
|
12
|
+
lastBeatmaps: z.array(
|
|
13
|
+
z.object({
|
|
14
|
+
id: z.number().nullable().optional(),
|
|
15
|
+
nominations: z.array(z.number()).nullable().optional(),
|
|
16
|
+
playcount: z.number().nullable().optional(),
|
|
17
|
+
created_at: z.string().nullable().optional(),
|
|
18
|
+
difficulty: z.number().nullable().optional(),
|
|
19
|
+
noteCount: z.number().nullable().optional(),
|
|
20
|
+
length: z.number().nullable().optional(),
|
|
21
|
+
title: z.string().nullable().optional(),
|
|
22
|
+
ranked: z.boolean().nullable().optional(),
|
|
23
|
+
beatmapFile: z.string().nullable().optional(),
|
|
24
|
+
image: z.string().nullable().optional(),
|
|
25
|
+
starRating: z.number().nullable().optional(),
|
|
26
|
+
owner: z.number().nullable().optional(),
|
|
27
|
+
ownerUsername: z.string().nullable().optional(),
|
|
28
|
+
ownerAvatar: z.string().nullable().optional(),
|
|
29
|
+
status: z.string().nullable().optional(),
|
|
30
|
+
})
|
|
31
|
+
),
|
|
12
32
|
}),
|
|
13
33
|
};
|
|
14
34
|
|
|
@@ -30,6 +50,33 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
30
50
|
.from("beatmaps")
|
|
31
51
|
.select("*", { count: "exact", head: true });
|
|
32
52
|
|
|
53
|
+
let { data: beatmapPage, error: errorlast } = await supabase
|
|
54
|
+
.from("beatmapPages")
|
|
55
|
+
.select(
|
|
56
|
+
`
|
|
57
|
+
*,
|
|
58
|
+
beatmaps (
|
|
59
|
+
created_at,
|
|
60
|
+
playcount,
|
|
61
|
+
length,
|
|
62
|
+
ranked,
|
|
63
|
+
beatmapFile,
|
|
64
|
+
image,
|
|
65
|
+
starRating,
|
|
66
|
+
difficulty,
|
|
67
|
+
noteCount,
|
|
68
|
+
title
|
|
69
|
+
),
|
|
70
|
+
profiles (
|
|
71
|
+
username,
|
|
72
|
+
avatar_url
|
|
73
|
+
)
|
|
74
|
+
`
|
|
75
|
+
)
|
|
76
|
+
.eq("status", "RANKED")
|
|
77
|
+
.order("created_at", { ascending: false })
|
|
78
|
+
.limit(4);
|
|
79
|
+
|
|
33
80
|
const countScoresQuery = await supabase
|
|
34
81
|
.from("scores")
|
|
35
82
|
.select("*", { count: "exact", head: true });
|
|
@@ -38,5 +85,23 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
38
85
|
beatmaps: countBeatmapsQuery.count,
|
|
39
86
|
profiles: countProfilesQuery.count,
|
|
40
87
|
scores: countScoresQuery.count,
|
|
88
|
+
lastBeatmaps: beatmapPage?.map((e) => ({
|
|
89
|
+
playcount: e.beatmaps?.playcount,
|
|
90
|
+
created_at: e.created_at,
|
|
91
|
+
difficulty: e.beatmaps?.difficulty,
|
|
92
|
+
noteCount: e.beatmaps?.noteCount,
|
|
93
|
+
length: e.beatmaps?.length,
|
|
94
|
+
title: e.beatmaps?.title,
|
|
95
|
+
ranked: e.beatmaps?.ranked,
|
|
96
|
+
beatmapFile: e.beatmaps?.beatmapFile,
|
|
97
|
+
image: e.beatmaps?.image,
|
|
98
|
+
starRating: e.beatmaps?.starRating,
|
|
99
|
+
owner: e.owner,
|
|
100
|
+
ownerUsername: e.profiles?.username,
|
|
101
|
+
ownerAvatar: e.profiles?.avatar_url,
|
|
102
|
+
id: e.id,
|
|
103
|
+
status: e.status,
|
|
104
|
+
nominations: e.nominations as number[],
|
|
105
|
+
})),
|
|
41
106
|
});
|
|
42
107
|
}
|
package/api/submitScore.ts
CHANGED
|
@@ -25,8 +25,10 @@ export const Schema = {
|
|
|
25
25
|
}),
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
function
|
|
29
|
-
|
|
28
|
+
function easeInExpoDeqHard(x: number, star: number) {
|
|
29
|
+
let exponent = 100 - 12 * star;
|
|
30
|
+
if (exponent < 5) exponent = 5;
|
|
31
|
+
return x === 0 ? 0 : Math.pow(2, exponent * x - exponent);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export function calculatePerformancePoints(
|
|
@@ -34,7 +36,10 @@ export function calculatePerformancePoints(
|
|
|
34
36
|
accuracy: number
|
|
35
37
|
) {
|
|
36
38
|
return Math.round(
|
|
37
|
-
Math.pow(
|
|
39
|
+
Math.pow(
|
|
40
|
+
(starRating * easeInExpoDeqHard(accuracy, starRating) * 100) / 2,
|
|
41
|
+
2
|
|
42
|
+
) / 1000
|
|
38
43
|
);
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -202,9 +207,9 @@ export async function handler({
|
|
|
202
207
|
|
|
203
208
|
for (const score of values) {
|
|
204
209
|
totalSp += ((score || 0) * weight) / 100;
|
|
205
|
-
weight
|
|
210
|
+
weight = weight * 0.97;
|
|
206
211
|
|
|
207
|
-
if (weight
|
|
212
|
+
if (weight < 5) {
|
|
208
213
|
break;
|
|
209
214
|
}
|
|
210
215
|
}
|
package/index.ts
CHANGED
|
@@ -418,6 +418,26 @@ export const Schema = {
|
|
|
418
418
|
profiles: z.number(),
|
|
419
419
|
beatmaps: z.number(),
|
|
420
420
|
scores: z.number(),
|
|
421
|
+
lastBeatmaps: z.array(
|
|
422
|
+
z.object({
|
|
423
|
+
id: z.number().nullable().optional(),
|
|
424
|
+
nominations: z.array(z.number()).nullable().optional(),
|
|
425
|
+
playcount: z.number().nullable().optional(),
|
|
426
|
+
created_at: z.string().nullable().optional(),
|
|
427
|
+
difficulty: z.number().nullable().optional(),
|
|
428
|
+
noteCount: z.number().nullable().optional(),
|
|
429
|
+
length: z.number().nullable().optional(),
|
|
430
|
+
title: z.string().nullable().optional(),
|
|
431
|
+
ranked: z.boolean().nullable().optional(),
|
|
432
|
+
beatmapFile: z.string().nullable().optional(),
|
|
433
|
+
image: z.string().nullable().optional(),
|
|
434
|
+
starRating: z.number().nullable().optional(),
|
|
435
|
+
owner: z.number().nullable().optional(),
|
|
436
|
+
ownerUsername: z.string().nullable().optional(),
|
|
437
|
+
ownerAvatar: z.string().nullable().optional(),
|
|
438
|
+
status: z.string().nullable().optional(),
|
|
439
|
+
})
|
|
440
|
+
),
|
|
421
441
|
}),
|
|
422
442
|
};*/
|
|
423
443
|
import { Schema as GetPublicStats } from "./api/getPublicStats"
|