fixed playcount tabulation
This commit is contained in:
@ -6,7 +6,6 @@ import type * as Prisma from "@prisma/client";
|
|||||||
|
|
||||||
type ChuniScorePlaylog = Prisma.PrismaClient;
|
type ChuniScorePlaylog = Prisma.PrismaClient;
|
||||||
type ChuniStaticMusic = Prisma.PrismaClient;
|
type ChuniStaticMusic = Prisma.PrismaClient;
|
||||||
|
|
||||||
export async function getSongsWithTitles(userId: number) {
|
export async function getSongsWithTitles(userId: number) {
|
||||||
try {
|
try {
|
||||||
const songs: ChuniScorePlaylog[] =
|
const songs: ChuniScorePlaylog[] =
|
||||||
@ -82,34 +81,14 @@ export async function getSongsWithTitles(userId: number) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const chuniScoreBest: chuni_score_best[] =
|
const playCounts = await artemis.chuni_score_playlog.groupBy({
|
||||||
await artemis.chuni_score_best.findMany({
|
by: ["musicId", "level"],
|
||||||
where: {
|
where: {
|
||||||
musicId: {
|
musicId: { in: chuniScorePlaylogMusicId },
|
||||||
in: chuniScorePlaylogMusicId,
|
user: userId,
|
||||||
},
|
},
|
||||||
},
|
_count: {
|
||||||
select: {
|
_all: true,
|
||||||
id: true,
|
|
||||||
user: true,
|
|
||||||
musicId: true,
|
|
||||||
level: true,
|
|
||||||
playCount: true,
|
|
||||||
scoreMax: true,
|
|
||||||
resRequestCount: true,
|
|
||||||
resAcceptCount: true,
|
|
||||||
resSuccessCount: true,
|
|
||||||
missCount: true,
|
|
||||||
maxComboCount: true,
|
|
||||||
isFullCombo: true,
|
|
||||||
isAllJustice: true,
|
|
||||||
isSuccess: true,
|
|
||||||
fullChain: true,
|
|
||||||
maxChain: true,
|
|
||||||
scoreRank: true,
|
|
||||||
isLock: true,
|
|
||||||
ext1: true,
|
|
||||||
theoryCount: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,9 +99,10 @@ export async function getSongsWithTitles(userId: number) {
|
|||||||
chuniStaticMusic.chartId === song.level,
|
chuniStaticMusic.chartId === song.level,
|
||||||
);
|
);
|
||||||
|
|
||||||
const bestScore = chuniScoreBest.find(
|
const playCount =
|
||||||
(score) => score.musicId === song.musicId,
|
playCounts.find(
|
||||||
);
|
(play) => play.musicId === song.musicId && play.level === song.level,
|
||||||
|
)?._count._all || 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...song,
|
...song,
|
||||||
@ -132,8 +112,7 @@ export async function getSongsWithTitles(userId: number) {
|
|||||||
chartId: staticInfo?.chartId || "Unknown chartId",
|
chartId: staticInfo?.chartId || "Unknown chartId",
|
||||||
level: staticInfo?.level || "Unknown Level",
|
level: staticInfo?.level || "Unknown Level",
|
||||||
chartlevel: song.level || "Unknown Level",
|
chartlevel: song.level || "Unknown Level",
|
||||||
playCount: bestScore?.playCount || 0,
|
playCount,
|
||||||
isSuccess: bestScore?.isSuccess || 0,
|
|
||||||
jacketPath: staticInfo?.jacketPath || "",
|
jacketPath: staticInfo?.jacketPath || "",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,8 @@ import { chuni_score_best } from "@/prisma/schemas/artemis/generated/artemis";
|
|||||||
import { getDifficultyText, getGrade } from "@/lib/helpers";
|
import { getDifficultyText, getGrade } from "@/lib/helpers";
|
||||||
import { Skeleton } from "../ui/skeleton";
|
import { Skeleton } from "../ui/skeleton";
|
||||||
import ActionsCell from "./moreAction";
|
import ActionsCell from "./moreAction";
|
||||||
type chunithm = chuni_score_playlog & chuni_static_music & chuni_score_best;
|
type chunithm = chuni_score_playlog &
|
||||||
|
chuni_static_music & { playCount: number };
|
||||||
|
|
||||||
export const columns: ColumnDef<chunithm>[] = [
|
export const columns: ColumnDef<chunithm>[] = [
|
||||||
{
|
{
|
||||||
@ -60,39 +61,11 @@ export const columns: ColumnDef<chunithm>[] = [
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const isSuccess = row.original.isSuccess;
|
|
||||||
const skillId = row.original.skillId;
|
|
||||||
let isSuccessText = "";
|
|
||||||
|
|
||||||
switch (isSuccess) {
|
|
||||||
case 0:
|
|
||||||
isSuccessText = " Clear";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
isSuccessText = "Clear";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
isSuccessText = "Hard";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
isSuccessText = "Absolute";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
isSuccessText = "Absolute+";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
isSuccessText = "Catastrophe";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
isSuccessText = isSuccess?.toString() ?? "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{row.original.score?.toLocaleString()}
|
{row.original.score?.toLocaleString()}
|
||||||
<div className="mt-2 w-24 rounded-sm bg-primary pl-2 text-primary-foreground">
|
<div className="mt-2 w-24 rounded-sm bg-primary pl-2 text-primary-foreground">
|
||||||
{isSuccessText}
|
e
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={`mt-2 w-24 rounded-sm pl-2 ${
|
className={`mt-2 w-24 rounded-sm pl-2 ${
|
||||||
|
Reference in New Issue
Block a user