removed uneeded comments
This commit is contained in:
@ -13,7 +13,7 @@ type LinkSharingToken = {
|
||||
|
||||
export async function getSongsWithTitles(userId: number) {
|
||||
try {
|
||||
// Fetch songs played by the user
|
||||
|
||||
const songs: ChuniScorePlaylog[] = await artemis.chuni_score_playlog.findMany({
|
||||
where: {
|
||||
user: userId,
|
||||
@ -68,7 +68,6 @@ export async function getSongsWithTitles(userId: number) {
|
||||
.map((song) => song.musicId)
|
||||
.filter((id): id is number => id !== null);
|
||||
|
||||
// Fetch static music information for the extracted musicIds
|
||||
const staticMusicInfo: ChuniStaticMusic[] = await artemis.chuni_static_music.findMany({
|
||||
where: {
|
||||
songId: {
|
||||
@ -86,7 +85,6 @@ export async function getSongsWithTitles(userId: number) {
|
||||
},
|
||||
});
|
||||
|
||||
// Fetch play count for each musicId specific to the user
|
||||
const playCounts = await artemis.chuni_score_playlog.groupBy({
|
||||
by: ['musicId'],
|
||||
_count: {
|
||||
@ -108,16 +106,13 @@ export async function getSongsWithTitles(userId: number) {
|
||||
return map;
|
||||
}, {} as Record<number, number>);
|
||||
|
||||
// Map each song with its corresponding static music information and play count
|
||||
const songsWithTitles = songs.map((song) => {
|
||||
// Find static info corresponding to the song's musicId and level (chartId)
|
||||
const staticInfo = staticMusicInfo.find(
|
||||
(chuniStaticMusic) =>
|
||||
chuniStaticMusic.songId === song.musicId &&
|
||||
chuniStaticMusic.chartId === song.level
|
||||
);
|
||||
|
||||
// Return mapped song with title, artist, genre, correct level, and play count
|
||||
return {
|
||||
...song,
|
||||
title: staticInfo?.title || "Unknown Title",
|
||||
|
Reference in New Issue
Block a user