rhythia-api 153.0.0 → 155.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.
@@ -9,6 +9,43 @@ 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
+ ),
32
+ topUsers: z.array(
33
+ z.object({
34
+ username: z.string(),
35
+ id: z.number(),
36
+ avatar_url: z.string(),
37
+ skill_points: z.number(),
38
+ })
39
+ ),
40
+ lastComments: z.array(
41
+ z.object({
42
+ owner: z.number(),
43
+ content: z.string(),
44
+ username: z.string(),
45
+ beatmapTitle: z.string(),
46
+ beatmapPage: z.number(),
47
+ })
48
+ ),
12
49
  }),
13
50
  };
14
51
 
@@ -30,6 +67,55 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
30
67
  .from("beatmaps")
31
68
  .select("*", { count: "exact", head: true });
32
69
 
70
+ let { data: beatmapPage, error: errorlast } = await supabase
71
+ .from("beatmapPages")
72
+ .select(
73
+ `
74
+ *,
75
+ beatmaps (
76
+ created_at,
77
+ playcount,
78
+ length,
79
+ ranked,
80
+ beatmapFile,
81
+ image,
82
+ starRating,
83
+ difficulty,
84
+ noteCount,
85
+ title
86
+ ),
87
+ profiles (
88
+ username,
89
+ avatar_url
90
+ )
91
+ `
92
+ )
93
+ .eq("status", "RANKED")
94
+ .order("created_at", { ascending: false })
95
+ .limit(4);
96
+
97
+ let { data: topUsers } = await supabase
98
+ .from("profiles")
99
+ .select("*")
100
+ .neq("ban", "excluded")
101
+ .order("skill_points", { ascending: false })
102
+ .limit(3);
103
+
104
+ let { data: comments } = await supabase
105
+ .from("beatmapPageComments")
106
+ .select(
107
+ `
108
+ *,
109
+ beatmapPages!inner(
110
+ *
111
+ ),
112
+ profiles!inner(
113
+ username
114
+ )`
115
+ )
116
+ .order("created_at", { ascending: false })
117
+ .limit(5);
118
+
33
119
  const countScoresQuery = await supabase
34
120
  .from("scores")
35
121
  .select("*", { count: "exact", head: true });
@@ -38,5 +124,36 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
38
124
  beatmaps: countBeatmapsQuery.count,
39
125
  profiles: countProfilesQuery.count,
40
126
  scores: countScoresQuery.count,
127
+ lastBeatmaps: beatmapPage?.map((e) => ({
128
+ playcount: e.beatmaps?.playcount,
129
+ created_at: e.created_at,
130
+ difficulty: e.beatmaps?.difficulty,
131
+ noteCount: e.beatmaps?.noteCount,
132
+ length: e.beatmaps?.length,
133
+ title: e.beatmaps?.title,
134
+ ranked: e.beatmaps?.ranked,
135
+ beatmapFile: e.beatmaps?.beatmapFile,
136
+ image: e.beatmaps?.image,
137
+ starRating: e.beatmaps?.starRating,
138
+ owner: e.owner,
139
+ ownerUsername: e.profiles?.username,
140
+ ownerAvatar: e.profiles?.avatar_url,
141
+ id: e.id,
142
+ status: e.status,
143
+ nominations: e.nominations as number[],
144
+ })),
145
+ topUsers: topUsers?.map((e) => ({
146
+ username: e.username,
147
+ id: e.id,
148
+ avatar_url: e.avatar_url,
149
+ skill_points: e.skill_points,
150
+ })),
151
+ lastComments: comments?.map((e) => ({
152
+ owner: e.owner,
153
+ content: e.content,
154
+ username: e.profiles.username,
155
+ beatmapTitle: e.beatmapPages.title,
156
+ beatmapPage: e.beatmapPages.id,
157
+ })),
41
158
  });
42
159
  }
@@ -25,8 +25,10 @@ export const Schema = {
25
25
  }),
26
26
  };
27
27
 
28
- function easeInExpoDeq(x: number) {
29
- return x === 0 ? 0 : Math.pow(2, 50 * x - 50);
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((starRating * easeInExpoDeq(accuracy) * 100) / 2, 2) / 1000
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 -= 1;
210
+ weight = weight * 0.97;
206
211
 
207
- if (weight == 0) {
212
+ if (weight < 5) {
208
213
  break;
209
214
  }
210
215
  }
package/index.ts CHANGED
@@ -418,6 +418,43 @@ 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
+ ),
441
+ topUsers: z.array(
442
+ z.object({
443
+ username: z.string(),
444
+ id: z.number(),
445
+ avatar_url: z.string(),
446
+ skill_points: z.number(),
447
+ })
448
+ ),
449
+ lastComments: z.array(
450
+ z.object({
451
+ owner: z.number(),
452
+ content: z.string(),
453
+ username: z.string(),
454
+ beatmapTitle: z.string(),
455
+ beatmapPage: z.number(),
456
+ })
457
+ ),
421
458
  }),
422
459
  };*/
423
460
  import { Schema as GetPublicStats } from "./api/getPublicStats"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "153.0.0",
3
+ "version": "155.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",