daphnis/components/RecentChunithmScores/action.ts

35 lines
927 B
TypeScript
Raw Normal View History

"use server";
import { getAuth } from "@/auth/queries/getauth";
import { supportedVersionNumber } from "@/lib/helpers";
import { artemis } from "@/lib/prisma";
export async function getUserRecentPlays() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
const userRatingBaseHotList = await artemis.chuni_profile_rating.findMany({
where: {
user: user.UserId,
// userRatingBaseList recent 30 // userRatingBaseHotList recent 15
type: "userRatingBaseList",
version: supportedVersionNumber, // TODO: eventually change this so the user can set their own version
},
select: {
score:true,
difficultId: true,
musicId: true,
type:true,
version: true,
romVersionCode: true,
id: true,
index:true,
user: true,
},
});
return userRatingBaseHotList;
}