mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Cleanup relation schema
This commit is contained in:
parent
781a9ae216
commit
a8d253fa2e
10 changed files with 404 additions and 291 deletions
|
|
@ -6,7 +6,7 @@ import SidebarSection from './SidebarSection.astro'
|
|||
import Looper from './CommentCarousel/Looper'
|
||||
|
||||
const comments = await prismaClient.comments.findMany({
|
||||
select: { text: true, albums: { select: { id: true, title: true } } },
|
||||
select: { text: true, album: { select: { id: true, title: true } } },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 5
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { useEffect, useRef, useState, type ButtonHTMLAttributes, type ReactNode
|
|||
interface Props {
|
||||
comments: {
|
||||
text: string | null
|
||||
albums: {
|
||||
album: {
|
||||
id: number
|
||||
title: string | null
|
||||
} | null
|
||||
|
|
@ -37,7 +37,7 @@ export default function Looper(props: Props) {
|
|||
<div className='text-md/6 font-extralight'>
|
||||
<div>{comment.text}</div>
|
||||
<div className='mt-1'>
|
||||
- <a href={`/album/${comment.albums?.id}`}>{comment.albums?.title}</a>
|
||||
- <a href={`/album/${comment.album?.id}`}>{comment.album?.title}</a>
|
||||
</div>
|
||||
{isMultiple ? (
|
||||
<div className='flex mt-2.5'>
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|||
context.locals.session = isAuthed.session
|
||||
|
||||
const user = await prismaClient.users.findUnique({
|
||||
select: { roleList: { select: { roles: { select: { permissions: true } } } } },
|
||||
select: { roles: { select: { roles: { select: { permissions: true } } } } },
|
||||
where: { id: isAuthed.user.id }
|
||||
})
|
||||
const permissions = (user?.roleList.map((r) => r.roles.permissions).flat() as string[]) ?? []
|
||||
const permissions = (user?.roles.map((r) => r.roles.permissions).flat() as string[]) ?? []
|
||||
const pages = PAGES.filter((p) => p.perms.some((r) => permissions.includes(r))).map((p) => p.url)
|
||||
|
||||
context.locals.permissions = permissions
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ const hasDirect = permissions.includes('SKIP_ADS')
|
|||
const album = await prismaClient.albums.findUnique({
|
||||
where: { id: Number(id) },
|
||||
include: {
|
||||
artistList: { select: { artist: true } },
|
||||
categoryList: { select: { categoryName: true } },
|
||||
classificationList: { select: { classificationName: true } },
|
||||
platformList: { select: { platform: { select: { id: true, name: true } } } },
|
||||
gameList: { select: { game: { select: { slug: true, name: true } } } },
|
||||
animList: { select: { animation: { select: { id: true, title: true } } } },
|
||||
artists: { select: { artist: true } },
|
||||
categories: { select: { categoryName: true } },
|
||||
classifications: { select: { classificationName: true } },
|
||||
platforms: { select: { platform: { select: { id: true, name: true } } } },
|
||||
games: { select: { game: { select: { slug: true, name: true } } } },
|
||||
animations: { select: { animation: { select: { id: true, title: true } } } },
|
||||
stores: { select: { url: true, provider: true }, where: { NOT: { provider: 'SOON' } } },
|
||||
discs: { select: { number: true, body: true } },
|
||||
downloads: {
|
||||
|
|
@ -35,7 +35,7 @@ const album = await prismaClient.albums.findUnique({
|
|||
links: { select: { id: true, url: true, url2: true, provider: true, directUrl: hasDirect } }
|
||||
}
|
||||
},
|
||||
relatedAlbumList: { select: { relatedAlbum: { select: { id: true, title: true } } } }
|
||||
relatedAlbums: { select: { relatedAlbum: { select: { id: true, title: true } } } }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -96,10 +96,10 @@ const { currentLocale } = Astro
|
|||
}
|
||||
|
||||
{
|
||||
(album?.artistList.length ?? 0) > 0 && (
|
||||
(album?.artists.length ?? 0) > 0 && (
|
||||
<tr>
|
||||
<th>{m.artists()}</th>
|
||||
<td>{album?.artistList.map(({ artist }) => artist.name).join(', ')}</td>
|
||||
<td>{album?.artists.map(({ artist }) => artist.name).join(', ')}</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
|
@ -109,10 +109,8 @@ const { currentLocale } = Astro
|
|||
<td>
|
||||
{
|
||||
[
|
||||
album?.categoryList
|
||||
.map(({ categoryName }) => (m as any)[`${categoryName}Osts`]())
|
||||
.join(' & '),
|
||||
album?.classificationList.map(({ classificationName }) => classificationName).join(', ')
|
||||
album?.categories.map(({ categoryName }) => (m as any)[`${categoryName}Osts`]()).join(' & '),
|
||||
album?.classifications.map(({ classificationName }) => classificationName).join(', ')
|
||||
]
|
||||
.filter((f) => f !== '')
|
||||
.join(' - ')
|
||||
|
|
@ -132,11 +130,11 @@ const { currentLocale } = Astro
|
|||
)
|
||||
}
|
||||
{
|
||||
(album?.platformList.length ?? 0) > 0 && (
|
||||
(album?.platforms.length ?? 0) > 0 && (
|
||||
<tr>
|
||||
<th>{m.platforms()}</th>
|
||||
<td>
|
||||
{album?.platformList.map(({ platform }, i) => (
|
||||
{album?.platforms.map(({ platform }, i) => (
|
||||
<Fragment key={platform.id}>
|
||||
{id === '29' ? (
|
||||
<span class='btn p-0' style={{ color: 'white' }}>
|
||||
|
|
@ -147,7 +145,7 @@ const { currentLocale } = Astro
|
|||
{platform.name}
|
||||
</a>
|
||||
)}
|
||||
{i !== album?.platformList.length - 1 && ', '}
|
||||
{i !== album?.platforms.length - 1 && ', '}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
|
|
@ -155,16 +153,16 @@ const { currentLocale } = Astro
|
|||
)
|
||||
}
|
||||
{
|
||||
(album?.gameList.length ?? 0) > 0 && (
|
||||
(album?.games.length ?? 0) > 0 && (
|
||||
<tr>
|
||||
<th>{m.games()}</th>
|
||||
<td>
|
||||
{album?.gameList.map(({ game }, i) => (
|
||||
{album?.games.map(({ game }, i) => (
|
||||
<Fragment key={game.slug}>
|
||||
<a class='btn btn-link p-0' href={`/game/${game.slug}`}>
|
||||
{game.name}
|
||||
</a>
|
||||
{i !== album?.gameList.length - 1 && ', '}
|
||||
{i !== album?.games.length - 1 && ', '}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
|
|
@ -172,16 +170,16 @@ const { currentLocale } = Astro
|
|||
)
|
||||
}
|
||||
{
|
||||
(album?.animList.length ?? 0) > 0 && (
|
||||
(album?.animations.length ?? 0) > 0 && (
|
||||
<tr>
|
||||
<th>{m.animations()}</th>
|
||||
<td>
|
||||
{album?.animList.map(({ animation }, i) => (
|
||||
{album?.animations.map(({ animation }, i) => (
|
||||
<Fragment key={id}>
|
||||
<a class='btn btn-link p-0' href={`/anim/${id}`}>
|
||||
{animation.title}
|
||||
</a>
|
||||
{i !== album?.animList.length - 1 && ', '}
|
||||
{i !== album?.animations.length - 1 && ', '}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
|
|
@ -343,7 +341,7 @@ const { currentLocale } = Astro
|
|||
<div class='mt-2'>
|
||||
<div class='grid grid-cols-4 gap-x-1.5 justify-items-center'>
|
||||
{
|
||||
album?.relatedAlbumList.map(({ relatedAlbum }) => (
|
||||
album?.relatedAlbums.map(({ relatedAlbum }) => (
|
||||
<AlbumBox
|
||||
title={relatedAlbum?.title}
|
||||
href={`/album/${relatedAlbum?.id}`}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import prismaClient from 'utils/prisma-client'
|
|||
export async function GET(context: APIContext) {
|
||||
const albums = await prismaClient.albums.findMany({
|
||||
where: { status: 'show' },
|
||||
include: { artistList: { include: { artist: { select: { name: true } } } } },
|
||||
include: { artists: { include: { artist: { select: { name: true } } } } },
|
||||
take: 15,
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
|
|
@ -14,7 +14,7 @@ export async function GET(context: APIContext) {
|
|||
guid: `album/${album.id}`,
|
||||
title: album.title || 'Error: Missing title',
|
||||
pubDate: new Date(album.createdAt || ''),
|
||||
description: album.subTitle || album.artistList.map((a) => a.artist.name).join(' - '),
|
||||
description: album.subTitle || album.artists.map((a) => a.artist.name).join(' - '),
|
||||
link: `https://www.sittingonclouds.net/album/${album.id}`,
|
||||
customData: `<media:content
|
||||
type="image/png"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue