feat(admin): show a candidate's languages
The candidate dialog lists the languages discovery recorded, with a "No English" badge when English is not among them. A row queued before discovery recorded languages shows "-", which is not the same as an empty list (a game that declares none). Auto-approve is unchanged: such a game is decided like any other. The mock server's payloads carry languages too, and it queues one game without English so the badge can be seen in dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4672f871b3
commit
7aef442b38
4 files changed
+93
-3
No files matched your search
+15
-1
@@ -18,6 +18,7 @@ interface Rec {
|
||||
release_date?: string;
|
||||
reviews?: string;
|
||||
current_players?: string;
|
||||
languages?: string[];
|
||||
}
|
||||
|
||||
const HOUR = 3_600_000;
|
||||
@@ -65,7 +66,14 @@ export function seed(sqlite: SqliteD1, repo: FakeRepo, records: Rec[], now: Date
|
||||
pct(r),
|
||||
r.current_players ?? "N/A",
|
||||
players(r),
|
||||
JSON.stringify({ link: r.link, name: r.name, reviews: r.reviews, current_players: r.current_players }),
|
||||
JSON.stringify({
|
||||
link: r.link,
|
||||
name: r.name,
|
||||
reviews: r.reviews,
|
||||
current_players: r.current_players,
|
||||
// Discovery records every candidate's languages since v4.6.0.
|
||||
languages: r.languages,
|
||||
}),
|
||||
extra.source ?? (n % 5 === 0 ? "backfill:2025" : "discover"),
|
||||
status,
|
||||
extra.by ?? null,
|
||||
@@ -93,6 +101,12 @@ export function seed(sqlite: SqliteD1, repo: FakeRepo, records: Rec[], now: Date
|
||||
};
|
||||
|
||||
for (let k = 0; k < 45; k++) row(hide(next()), "pending");
|
||||
// A game whose store page lists no English, for the dialog's "No English" badge.
|
||||
// Outside the pool, so it never meets another open row for the same game.
|
||||
const foreign = records.find(
|
||||
(r) => !pool.includes(r) && r.name && r.header_image && r.languages?.length && !r.languages.includes("English"),
|
||||
);
|
||||
if (foreign) row(hide(foreign), "pending", { seenAgo: HOUR / 2 });
|
||||
for (let k = 0; k < 6; k++) row(hide(next()), "deferred", { seenAgo: (60 + k) * HOUR });
|
||||
row(hide(next()), "failed", { reason: "never appeared in data/ or removed_games.jsonl - approve again to retry", by: reviewer, at: iso(30 * HOUR) });
|
||||
row(hide(next()), "failed", { reason: "rejected by ingest pipeline", by: reviewer, at: iso(50 * HOUR) });
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exactTime, plural, prettyJson, rangeLabel, relativeTime, shortSha, showValue } from "./format";
|
||||
import {
|
||||
exactTime,
|
||||
lacksEnglish,
|
||||
languagesLabel,
|
||||
payloadLanguages,
|
||||
plural,
|
||||
prettyJson,
|
||||
rangeLabel,
|
||||
relativeTime,
|
||||
shortSha,
|
||||
showValue,
|
||||
} from "./format";
|
||||
|
||||
const NOW = Date.parse("2026-09-17T12:00:00Z");
|
||||
|
||||
@@ -40,4 +51,28 @@ describe("format", () => {
|
||||
expect(prettyJson('{"a":1}')).toBe('{\n "a": 1\n}');
|
||||
expect(prettyJson("{broken")).toBe("{broken");
|
||||
});
|
||||
|
||||
it("payloadLanguages tells no list from an empty one", () => {
|
||||
expect(payloadLanguages('{"languages":["Japanese"]}')).toEqual(["Japanese"]);
|
||||
expect(payloadLanguages('{"languages":[]}')).toEqual([]);
|
||||
expect(payloadLanguages('{"languages":["English",3,null,"Korean"]}')).toEqual(["English", "Korean"]);
|
||||
// Queued before v4.6.0, or not a payload at all.
|
||||
expect(payloadLanguages('{"short_description":"x"}')).toBeNull();
|
||||
expect(payloadLanguages('{"languages":"Japanese"}')).toBeNull();
|
||||
expect(payloadLanguages("{broken")).toBeNull();
|
||||
expect(payloadLanguages("null")).toBeNull();
|
||||
expect(payloadLanguages("7")).toBeNull();
|
||||
expect(payloadLanguages("")).toBeNull();
|
||||
expect(payloadLanguages(undefined)).toBeNull();
|
||||
});
|
||||
|
||||
it("languagesLabel and lacksEnglish", () => {
|
||||
expect(languagesLabel(["Japanese", "Korean"])).toBe("Japanese, Korean");
|
||||
expect(languagesLabel([])).toBe("none declared");
|
||||
expect(languagesLabel(null)).toBe("—");
|
||||
expect(lacksEnglish(["Japanese"])).toBe(true);
|
||||
expect(lacksEnglish([])).toBe(true);
|
||||
expect(lacksEnglish(["English", "Japanese"])).toBe(false);
|
||||
expect(lacksEnglish(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -61,6 +61,35 @@ export function prettyJson(text: string | null | undefined): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The languages a candidate's payload lists: English names, as discovery read
|
||||
* them from appdetails. `null` when there is no list - rows queued before
|
||||
* discovery took games in every language (v4.6.0), or a payload that does not
|
||||
* parse - which is not the same as `[]`, a game that declares no language.
|
||||
*/
|
||||
export function payloadLanguages(text: string | null | undefined): string[] | null {
|
||||
if (!text) return null;
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(text);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
const list = (parsed as { languages?: unknown } | null)?.languages;
|
||||
if (!Array.isArray(list)) return null;
|
||||
return list.filter((l): l is string => typeof l === "string");
|
||||
}
|
||||
|
||||
/** The languages as the candidate dialog shows them. */
|
||||
export function languagesLabel(languages: string[] | null): string {
|
||||
if (languages === null) return "—";
|
||||
return languages.length ? languages.join(", ") : "none declared";
|
||||
}
|
||||
|
||||
/** A known list without English: a reader of English cannot play the game. */
|
||||
export const lacksEnglish = (languages: string[] | null): boolean =>
|
||||
languages !== null && !languages.includes("English");
|
||||
|
||||
/** "1-50 of 646" for a pager. */
|
||||
export function rangeLabel(offset: number, count: number, total: number): string {
|
||||
if (!total || !count) return `0 of ${formatInt(total)}`;
|
||||
|
||||
@@ -21,7 +21,15 @@
|
||||
import StatusBadge from "../components/StatusBadge.svelte";
|
||||
import { api, errorMessage, SessionExpiredError } from "../lib/api";
|
||||
import { isAbort, reportError } from "../lib/notify";
|
||||
import { exactTime, prettyJson, relativeTime, steamUrl } from "../lib/format";
|
||||
import {
|
||||
exactTime,
|
||||
lacksEnglish,
|
||||
languagesLabel,
|
||||
payloadLanguages,
|
||||
prettyJson,
|
||||
relativeTime,
|
||||
steamUrl,
|
||||
} from "../lib/format";
|
||||
import { LOCK_HELP, REOPEN_TEXT } from "../lib/labels";
|
||||
import { lockReason } from "../../../shared/queue-rules";
|
||||
import { REMOVED_DECISION_PREFIX } from "../../../shared/removal";
|
||||
@@ -67,6 +75,8 @@
|
||||
});
|
||||
|
||||
const lock = $derived(data ? lockReason(data) : null);
|
||||
// Discovery takes games in every language since v4.6.0; older rows have no list.
|
||||
const languages = $derived(data ? payloadLanguages(data.payload_json) : null);
|
||||
|
||||
async function reopen() {
|
||||
if (!data || reopening) return;
|
||||
@@ -119,6 +129,7 @@
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<StatusBadge status={data.status} />
|
||||
{#if data.published}<Badge variant="success">in the catalogue</Badge>{/if}
|
||||
{#if lacksEnglish(languages)}<Badge variant="info">No English</Badge>{/if}
|
||||
<span class="font-mono text-xs text-muted-foreground">appid {data.appid}</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
||||
@@ -145,6 +156,7 @@
|
||||
{@render fact("Type", data.app_type)}
|
||||
{@render fact("Free to play", data.is_free ? "yes" : "no")}
|
||||
{@render fact("Store health", data.health_status)}
|
||||
{@render fact("Languages", languagesLabel(languages), languagesLabel(languages))}
|
||||
{@render fact("First seen", relativeTime(data.first_seen_at), exactTime(data.first_seen_at))}
|
||||
{@render fact("Last seen", relativeTime(data.last_seen_at), exactTime(data.last_seen_at))}
|
||||
{@render fact("Times seen", String(data.seen_count))}
|
||||
|
||||
Reference in new issue
Block a user