forked from PolarisPyra/daphnis
fixed rating calculation
This commit is contained in:
parent
7fa7747b62
commit
64da6391f3
@ -34,6 +34,7 @@ export async function getUserRatingBaseList() {
|
|||||||
songId: {
|
songId: {
|
||||||
in: baseListMusicIds,
|
in: baseListMusicIds,
|
||||||
},
|
},
|
||||||
|
version: supportedVersionNumber, // Ensure the version matches
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
songId: true,
|
songId: true,
|
||||||
@ -47,18 +48,23 @@ export async function getUserRatingBaseList() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const staticMusic = new Map(
|
// Map to join `musicId` and `difficultId` with static music info
|
||||||
staticMusicInfo.map((info) => [info.songId, info]),
|
// i hate it
|
||||||
);
|
const profileRatingToStaticMusic = new Map<
|
||||||
|
string,
|
||||||
|
(typeof staticMusicInfo)[0]
|
||||||
|
>(staticMusicInfo.map((info) => [`${info.songId}-${info.chartId}`, info]));
|
||||||
|
|
||||||
const songsWithTitles = userRatingBaseList.map((ratingListSong) => {
|
const songsWithTitles = userRatingBaseList.map((ratingListSong) => {
|
||||||
const staticInfo = staticMusic.get(ratingListSong.musicId);
|
const MusicIdtoDiffId = `${ratingListSong.musicId}-${ratingListSong.difficultId}`;
|
||||||
|
const songInfo = profileRatingToStaticMusic.get(MusicIdtoDiffId);
|
||||||
|
|
||||||
const level = staticInfo?.level ?? 0;
|
const level = songInfo?.level ?? 0;
|
||||||
const score = ratingListSong.score ?? 0;
|
const score = ratingListSong.score ?? 0;
|
||||||
|
|
||||||
// Calculate the rating
|
// Calculate the rating
|
||||||
let rating = 0;
|
let rating = 0;
|
||||||
|
|
||||||
if (score >= 1009000) {
|
if (score >= 1009000) {
|
||||||
rating = level * 100 + 215;
|
rating = level * 100 + 215;
|
||||||
} else if (score >= 1007500) {
|
} else if (score >= 1007500) {
|
||||||
@ -81,12 +87,12 @@ export async function getUserRatingBaseList() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...ratingListSong,
|
...ratingListSong,
|
||||||
title: staticInfo?.title || "Unknown Title",
|
title: songInfo?.title || "Unknown Title",
|
||||||
artist: staticInfo?.artist || "Unknown Artist",
|
artist: songInfo?.artist || "Unknown Artist",
|
||||||
genre: staticInfo?.genre || "Unknown Genre",
|
genre: songInfo?.genre || "Unknown Genre",
|
||||||
chartId: staticInfo?.chartId || "Unknown chartId",
|
chartId: songInfo?.chartId || "Unknown chartId",
|
||||||
level: staticInfo?.level || "Unknown Level",
|
level: songInfo?.level || "Unknown Level",
|
||||||
jacketPath: staticInfo?.jacketPath || "",
|
jacketPath: songInfo?.jacketPath || "",
|
||||||
rating,
|
rating,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -179,6 +179,7 @@ const config = {
|
|||||||
"db"
|
"db"
|
||||||
],
|
],
|
||||||
"activeProvider": "mysql",
|
"activeProvider": "mysql",
|
||||||
|
"postinstall": false,
|
||||||
"inlineDatasources": {
|
"inlineDatasources": {
|
||||||
"db": {
|
"db": {
|
||||||
"url": {
|
"url": {
|
||||||
|
@ -180,6 +180,7 @@ const config = {
|
|||||||
"db"
|
"db"
|
||||||
],
|
],
|
||||||
"activeProvider": "mysql",
|
"activeProvider": "mysql",
|
||||||
|
"postinstall": false,
|
||||||
"inlineDatasources": {
|
"inlineDatasources": {
|
||||||
"db": {
|
"db": {
|
||||||
"url": {
|
"url": {
|
||||||
|
Loading…
Reference in New Issue
Block a user