Add entry ports and scores

Surface ports, remakes, scores, and notes on entry detail.

Signed-off-by: codex@lucy.xalior.com
This commit is contained in:
2026-01-10 18:26:34 +00:00
parent d9f55c3eb6
commit 964b48abf1
2 changed files with 314 additions and 0 deletions

View File

@@ -39,6 +39,12 @@ import {
tags,
tagtypes,
members,
ports,
platforms,
remakes,
scores,
notes,
notetypes,
webrefs,
websites,
magazines,
@@ -319,6 +325,34 @@ export interface EntryDetail {
link: string | null;
comments: string | null;
}[];
ports?: {
id: number;
title: string | null;
platform: { id: number; name: string | null };
isOfficial: boolean;
linkSystem: string | null;
}[];
remakes?: {
id: number;
title: string;
fileLink: string;
fileDate: string | null;
fileSize: number | null;
authors: string | null;
platforms: string | null;
remakeYears: string | null;
remakeStatus: string | null;
}[];
scores?: {
website: { id: number; name: string | null };
score: number;
votes: number;
}[];
notes?: {
id: number;
type: { id: string; name: string | null };
text: string;
}[];
origins?: {
type: { id: string; name: string | null };
libraryTitle: string;
@@ -627,6 +661,37 @@ export async function getEntryById(id: number): Promise<EntryDetail | null> {
link: string | null;
comments: string | null;
}[] = [];
let portRows: {
id: number | string;
title: string | null;
platformId: number | string;
platformName: string | null;
isOfficial: number | boolean;
linkSystem: string | null;
}[] = [];
let remakeRows: {
id: number | string;
title: string;
fileLink: string;
fileDate: string | null;
fileSize: number | string | null;
authors: string | null;
platforms: string | null;
remakeYears: string | null;
remakeStatus: string | null;
}[] = [];
let scoreRows: {
websiteId: number | string;
websiteName: string | null;
score: number | string;
votes: number | string;
}[] = [];
let noteRows: {
id: number | string;
notetypeId: string;
notetypeName: string | null;
text: string;
}[] = [];
try {
aliasRows = await db
.select({ releaseSeq: aliases.releaseSeq, languageId: aliases.languageId, title: aliases.title })
@@ -741,6 +806,67 @@ export async function getEntryById(id: number): Promise<EntryDetail | null> {
);
tagRows = rows as typeof tagRows;
} catch {}
try {
const rows = await db
.select({
id: ports.id,
title: ports.title,
platformId: ports.platformId,
platformName: platforms.name,
isOfficial: ports.isOfficial,
linkSystem: ports.linkSystem,
})
.from(ports)
.leftJoin(platforms, eq(platforms.id, ports.platformId))
.where(eq(ports.entryId, id))
.orderBy(asc(ports.title));
portRows = rows as typeof portRows;
} catch {}
try {
const rows = await db
.select({
id: remakes.id,
title: remakes.title,
fileLink: remakes.fileLink,
fileDate: remakes.fileDate,
fileSize: remakes.fileSize,
authors: remakes.authors,
platforms: remakes.platforms,
remakeYears: remakes.remakeYears,
remakeStatus: remakes.remakeStatus,
})
.from(remakes)
.where(eq(remakes.entryId, id))
.orderBy(asc(remakes.title));
remakeRows = rows as typeof remakeRows;
} catch {}
try {
const rows = await db
.select({
websiteId: websites.id,
websiteName: websites.name,
score: scores.score,
votes: scores.votes,
})
.from(scores)
.innerJoin(websites, eq(websites.id, scores.websiteId))
.where(eq(scores.entryId, id));
scoreRows = rows as typeof scoreRows;
} catch {}
try {
const rows = await db
.select({
id: notes.id,
notetypeId: notes.notetypeId,
notetypeName: notetypes.name,
text: notes.text,
})
.from(notes)
.leftJoin(notetypes, eq(notetypes.id, notes.notetypeId))
.where(eq(notes.entryId, id))
.orderBy(asc(notes.id));
noteRows = rows as typeof noteRows;
} catch {}
return {
id: base.id,
@@ -781,6 +907,34 @@ export async function getEntryById(id: number): Promise<EntryDetail | null> {
link: t.link ?? null,
comments: t.comments ?? null,
})),
ports: portRows.map((p) => ({
id: Number(p.id),
title: p.title ?? null,
platform: { id: Number(p.platformId), name: p.platformName ?? null },
isOfficial: !!p.isOfficial,
linkSystem: p.linkSystem ?? null,
})),
remakes: remakeRows.map((r) => ({
id: Number(r.id),
title: r.title,
fileLink: r.fileLink,
fileDate: r.fileDate ?? null,
fileSize: r.fileSize != null ? Number(r.fileSize) : null,
authors: r.authors ?? null,
platforms: r.platforms ?? null,
remakeYears: r.remakeYears ?? null,
remakeStatus: r.remakeStatus ?? null,
})),
scores: scoreRows.map((s) => ({
website: { id: Number(s.websiteId), name: s.websiteName ?? null },
score: Number(s.score),
votes: Number(s.votes),
})),
notes: noteRows.map((n) => ({
id: Number(n.id),
type: { id: n.notetypeId, name: n.notetypeName ?? null },
text: n.text,
})),
origins: originRows.map((o) => ({
type: { id: o.origintypeId, name: o.origintypeName ?? null },
libraryTitle: o.libraryTitle,