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