arcana type magic
This commit is contained in:
28
lib/api.ts
28
lib/api.ts
@ -1,14 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import { getAuth } from "@/auth/queries/getauth";
|
||||
import { artemis } from "@/lib/prisma";
|
||||
import { daphnis } from "@/lib/prisma";
|
||||
import { artemis, daphnis } from "@/lib/prisma";
|
||||
import type * as Prisma from '@prisma/client';
|
||||
|
||||
type ChuniScorePlaylog = Prisma.PrismaClient;
|
||||
type ChuniStaticMusic = Prisma.PrismaClient;
|
||||
type LinkSharingToken = {
|
||||
playlogId: number;
|
||||
};
|
||||
|
||||
export async function getSongsWithTitles(userId: number) {
|
||||
try {
|
||||
// Fetch songs from ChuniScorePlaylog
|
||||
const songs = await artemis.chuni_score_playlog.findMany({
|
||||
const songs: ChuniScorePlaylog[] = await artemis.chuni_score_playlog.findMany({
|
||||
where: {
|
||||
user: userId,
|
||||
},
|
||||
@ -55,15 +59,13 @@ export async function getSongsWithTitles(userId: number) {
|
||||
placeId: true,
|
||||
ticketId: true,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
const musicIds = songs
|
||||
.map((song) => song.musicId)
|
||||
.filter((id) => id !== null) as number[];
|
||||
|
||||
const staticMusicInfo = await artemis.chuni_static_music.findMany({
|
||||
const staticMusicInfo: ChuniStaticMusic[] = await artemis.chuni_static_music.findMany({
|
||||
where: {
|
||||
songId: {
|
||||
in: musicIds,
|
||||
@ -76,7 +78,6 @@ export async function getSongsWithTitles(userId: number) {
|
||||
},
|
||||
});
|
||||
|
||||
// Map titles to songs based on musicId
|
||||
const songsWithTitles = songs.map((song) => ({
|
||||
...song,
|
||||
title:
|
||||
@ -103,12 +104,11 @@ export async function SharingPlaylogId(playlogid: number) {
|
||||
select: {
|
||||
playlogId: true,
|
||||
},
|
||||
});
|
||||
}) as LinkSharingToken[];
|
||||
|
||||
// Extracting playlogId values from the fetched tokens
|
||||
const playlogIds = tokens.map((token) => token.playlogId);
|
||||
const playlogIds: number[] = tokens.map((token) => token.playlogId);
|
||||
|
||||
return playlogIds; // Returning an array of playlogIds
|
||||
return playlogIds;
|
||||
} catch (error) {
|
||||
console.error("Error fetching playlogIds:", error);
|
||||
throw error;
|
||||
@ -116,7 +116,7 @@ export async function SharingPlaylogId(playlogid: number) {
|
||||
}
|
||||
|
||||
export const getUsername = async () => {
|
||||
const { user } = await getAuth(); // Assuming getAuth() returns an auth object with user info
|
||||
const { user } = await getAuth();
|
||||
if (user) {
|
||||
return await daphnis.user.findFirst({
|
||||
where: {
|
||||
@ -125,7 +125,7 @@ export const getUsername = async () => {
|
||||
},
|
||||
});
|
||||
}
|
||||
return null; // Return null if no user is found
|
||||
return null;
|
||||
};
|
||||
|
||||
export async function getAllAimeCards() {
|
||||
|
Reference in New Issue
Block a user