style updates
This commit is contained in:
@ -21,18 +21,18 @@ export async function getUserRatingBaseList() {
|
|||||||
musicId: true,
|
musicId: true,
|
||||||
score: true,
|
score: true,
|
||||||
difficultId: true,
|
difficultId: true,
|
||||||
romVersionCode: true,
|
|
||||||
version: true,
|
version: true,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
|
orderBy: {
|
||||||
|
index: "asc",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const baseListMusicIds = userRatingBaseList.map((entry) => entry.musicId!);
|
|
||||||
|
|
||||||
const staticMusicInfo = await artemis.chuni_static_music.findMany({
|
const staticMusicInfo = await artemis.chuni_static_music.findMany({
|
||||||
where: {
|
where: {
|
||||||
songId: {
|
songId: {
|
||||||
in: baseListMusicIds,
|
in: userRatingBaseList.map((entry) => entry.musicId!),
|
||||||
},
|
},
|
||||||
version: supportedVersionNumber,
|
version: supportedVersionNumber,
|
||||||
},
|
},
|
||||||
@ -43,65 +43,70 @@ export async function getUserRatingBaseList() {
|
|||||||
chartId: true,
|
chartId: true,
|
||||||
level: true,
|
level: true,
|
||||||
genre: true,
|
genre: true,
|
||||||
worldsEndTag: true,
|
|
||||||
jacketPath: true,
|
jacketPath: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Map to join `musicId` and `difficultId` with static music info
|
// Create a map
|
||||||
// i hate it
|
const songIdtoChartId = new Map<string, (typeof staticMusicInfo)[0]>(
|
||||||
const profileRatingToStaticMusic = new Map<
|
staticMusicInfo.map((music) => [
|
||||||
string,
|
`${music.songId}-${music.chartId}`,
|
||||||
(typeof staticMusicInfo)[0]
|
music,
|
||||||
>(staticMusicInfo.map((info) => [`${info.songId}-${info.chartId}`, info]));
|
]),
|
||||||
|
|
||||||
const songsWithStaticMusicInfo = userRatingBaseList.map(
|
|
||||||
(ratingListSong) => {
|
|
||||||
const MusicIdtoDiffId = `${ratingListSong.musicId}-${ratingListSong.difficultId}`;
|
|
||||||
const songInfo = profileRatingToStaticMusic.get(MusicIdtoDiffId);
|
|
||||||
|
|
||||||
const level = songInfo?.level ?? 0;
|
|
||||||
const score = ratingListSong.score ?? 0;
|
|
||||||
|
|
||||||
// Rating Formula
|
|
||||||
let rating = 0;
|
|
||||||
|
|
||||||
if (score >= 1009000) {
|
|
||||||
rating = level * 100 + 215;
|
|
||||||
} else if (score >= 1007500) {
|
|
||||||
rating = level * 100 + 200 + (score - 1007500) / 100;
|
|
||||||
} else if (score >= 1005000) {
|
|
||||||
rating = level * 100 + 150 + (score - 1005000) / 50;
|
|
||||||
} else if (score >= 1000000) {
|
|
||||||
rating = level * 100 + 100 + (score - 1000000) / 100;
|
|
||||||
} else if (score >= 975000) {
|
|
||||||
rating = level * 100 + (score - 975000) / 250;
|
|
||||||
} else if (score >= 925000) {
|
|
||||||
rating = level * 100 - 300 + ((score - 925000) * 3) / 500;
|
|
||||||
} else if (score >= 900000) {
|
|
||||||
rating = level * 100 - 500 + ((score - 900000) * 4) / 500;
|
|
||||||
} else if (score >= 800000) {
|
|
||||||
rating =
|
|
||||||
(level * 100 - 500) / 2 +
|
|
||||||
((score - 800000) * ((level - 500) / 2)) / 100000;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...ratingListSong,
|
|
||||||
title: songInfo?.title || "Unknown Title",
|
|
||||||
artist: songInfo?.artist || "Unknown Artist",
|
|
||||||
genre: songInfo?.genre || "Unknown Genre",
|
|
||||||
chartId: songInfo?.chartId || "Unknown chartId",
|
|
||||||
level: songInfo?.level || "Unknown Level",
|
|
||||||
jacketPath: songInfo?.jacketPath || "",
|
|
||||||
rating,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return songsWithStaticMusicInfo;
|
// user ratings
|
||||||
|
const musicIdToDifficltId = userRatingBaseList.map((rating) => {
|
||||||
|
const staticMusic = songIdtoChartId.get(
|
||||||
|
`${rating.musicId}-${rating.difficultId}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const level = staticMusic?.level ?? 0;
|
||||||
|
const score = rating.score ?? 0;
|
||||||
|
|
||||||
|
const ratingChange = calculateRating(level, score);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...rating,
|
||||||
|
chartId: staticMusic?.chartId || "Unknown chartId",
|
||||||
|
title: staticMusic?.title || "Unknown Title",
|
||||||
|
artist: staticMusic?.artist || "Unknown Artist",
|
||||||
|
genre: staticMusic?.genre || "Unknown Genre",
|
||||||
|
level: staticMusic?.level || "Unknown Level",
|
||||||
|
jacketPath: staticMusic?.jacketPath || "",
|
||||||
|
rating: ratingChange,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return musicIdToDifficltId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching songs with titles:", error);
|
console.error("Error fetching songs with titles:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate the rating
|
||||||
|
function calculateRating(level: number, score: number): number {
|
||||||
|
if (score >= 1009000) {
|
||||||
|
return level * 100 + 215;
|
||||||
|
} else if (score >= 1007500) {
|
||||||
|
return level * 100 + 200 + (score - 1007500) / 100;
|
||||||
|
} else if (score >= 1005000) {
|
||||||
|
return level * 100 + 150 + (score - 1005000) / 50;
|
||||||
|
} else if (score >= 1000000) {
|
||||||
|
return level * 100 + 100 + (score - 1000000) / 100;
|
||||||
|
} else if (score >= 975000) {
|
||||||
|
return level * 100 + (score - 975000) / 250;
|
||||||
|
} else if (score >= 925000) {
|
||||||
|
return level * 100 - 300 + ((score - 925000) * 3) / 500;
|
||||||
|
} else if (score >= 900000) {
|
||||||
|
return level * 100 - 500 + ((score - 900000) * 4) / 500;
|
||||||
|
} else if (score >= 800000) {
|
||||||
|
return (
|
||||||
|
(level * 100 - 500) / 2 +
|
||||||
|
((score - 800000) * ((level - 500) / 2)) / 100000
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,20 +3,20 @@ import {
|
|||||||
chuni_profile_rating,
|
chuni_profile_rating,
|
||||||
chuni_static_music,
|
chuni_static_music,
|
||||||
} from "@/prisma/schemas/artemis/generated/artemis";
|
} from "@/prisma/schemas/artemis/generated/artemis";
|
||||||
|
import { getDifficultyText } from "@/lib/helpers";
|
||||||
|
|
||||||
type userRatingBaseList = {
|
type userRatingBaseList = {
|
||||||
title: string;
|
title: string;
|
||||||
artist: string;
|
artist: string;
|
||||||
genre: string;
|
genre: string;
|
||||||
chartId: string | number;
|
chartId: number;
|
||||||
level: string | number;
|
level: string | number;
|
||||||
jacketPath: string;
|
jacketPath: string;
|
||||||
rating: number;
|
rating: number;
|
||||||
version: number;
|
version: number;
|
||||||
index: number;
|
index: number;
|
||||||
musicId: number | null;
|
musicId: number | null;
|
||||||
difficultId: number | null;
|
difficultId: string;
|
||||||
romVersionCode: number | null;
|
|
||||||
score: number | null;
|
score: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export const ChunithmRecentPlays: FC<ChunithmProfileRecentPlays> = ({
|
|||||||
<img
|
<img
|
||||||
src={`/JacketArt/${jacketPath}`}
|
src={`/JacketArt/${jacketPath}`}
|
||||||
alt="Jacket"
|
alt="Jacket"
|
||||||
style={{ width: "80px", height: "80px" }}
|
style={{ width: "120px", height: "120px" }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
@ -52,6 +52,13 @@ export const ChunithmRecentPlays: FC<ChunithmProfileRecentPlays> = ({
|
|||||||
<li>
|
<li>
|
||||||
<strong>Title: </strong> {playersRecentRatingList.title}
|
<strong>Title: </strong> {playersRecentRatingList.title}
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Level: </strong> {playersRecentRatingList.level}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Difficulty: </strong>
|
||||||
|
{getDifficultyText(playersRecentRatingList.chartId)}
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Score: </strong>{" "}
|
<strong>Score: </strong>{" "}
|
||||||
{playersRecentRatingList.score?.toLocaleString()}
|
{playersRecentRatingList.score?.toLocaleString()}
|
||||||
|
@ -36,7 +36,6 @@ export const getDifficultyText = (chartId: number | null) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getGrade = (score: number) => {
|
export const getGrade = (score: number) => {
|
||||||
if (score >= 1009000) return "SSS+";
|
if (score >= 1009000) return "SSS+";
|
||||||
if (score >= 1007500 && score <= 1008999) return "SSS";
|
if (score >= 1007500 && score <= 1008999) return "SSS";
|
||||||
|
Reference in New Issue
Block a user