master @ 146 LINES
[ HISTORY ] [ UP ]
┌─ ASTRO ────────────────────────────────────────────────────────────────────┐
│ --- │
│ import Callout from "../../components/Callout/Callout.astro"; │
│ import PageLayout from "../../layouts/PageLayout.astro"; │
│ import PlayerSearch from "../../components/PlayerSearch/PlayerSearch.astro"; │
│ import "../../styles/global.scss"; │
│ import "../../components/Status/StatusRunsTable/StatusRunsTable.scss"; │
│ import "../../components/Leaderboard/LeaderboardHeader/LeaderboardHeader.scss"; │
│ import type { │
│ CoverageHealth, │
│ RealmCoverage, │
│ StatusApiResponse, │
│ } from "../../lib/types"; │
│ import { readFile } from "node:fs/promises"; │
│ import { join } from "node:path"; │
│ import StatusRealmContainer from "../../components/Status/StatusRealmContainer/Sta │
│ tusRealmContainer.astro"; │
│ import LeaderboardTypeNav from "../../components/Leaderboard/LeaderboardTypeNav/Le │
│ aderboardTypeNav.astro"; │
│ │
│ const filePath = join( │
│ process.cwd(), │
│ "public", │
│ "api", │
│ "status", │
│ "latest-runs.json", │
│ ); │
│ const fileContent = await readFile(filePath, "utf-8"); │
│ const data = JSON.parse(fileContent) as StatusApiResponse; │
│ const realms = Array.isArray(data.realms) ? data.realms : []; │
│ │
│ const healthLabels: Record<CoverageHealth, string> = { │
│ ok: "OK", │
│ some_missing: "Some missing", │
│ no_data: "No data", │
│ }; │
│ │
│ const formatList = (items?: number[]) => │
│ items && items.length ? items.join(", ") : "None"; │
│ │
│ const latestPeriodByRegion = realms.reduce<Record<string, number | null>>( │
│ (acc, realm) => { │
│ const regionKey = realm.region.toUpperCase(); │
│ let currentMax = acc[regionKey] ?? null; │
│ realm.dungeons.forEach((dungeon) => { │
│ (dungeon.periods || []).forEach((period) => { │
│ if (currentMax === null || period > currentMax) { │
│ currentMax = period; │
│ } │
│ }); │
│ }); │
│ acc[regionKey] = currentMax; │
│ return acc; │
│ }, │
│ {}, │
│ ); │
│ │
│ const realmsByRegion = realms.reduce<Record<string, RealmCoverage[]>>( │
│ (acc, realm) => { │
│ const regionKey = realm.region.toUpperCase(); │
│ if (!acc[regionKey]) { │
│ acc[regionKey] = []; │
│ } │
│ acc[regionKey].push(realm); │
│ acc[regionKey].sort((a, b) => a.realm_name.localeCompare(b.realm_name)); │
│ return acc; │
│ }, │
│ {}, │
│ ); │
│ │
│ const regionEntries = Object.entries(realmsByRegion).sort((a, b) => │
│ a[0].localeCompare(b[0]), │
│ ); │
│ --- │
│ │
│ <PageLayout title="Challenge Mode Status"> │
│ <main class="leaderboard-page"> │
│ <h1 class="leaderboard-header status-page__title"> │
│ <span class="header-text">Challenge Mode Fetch Status</span> │
│ </h1> │
│ <PlayerSearch /> │
│ <LeaderboardTypeNav currentTab="status" /> │
│ │
│ <Callout type="note"> │
│ <p> │
│ Periods refer to one week long intervals within a challenge mode season. │
│ </p> │
│ </Callout> │
│ │
│ <div class="status-content"> │
│ { │
│ regionEntries.length === 0 ? ( │
│ <p class="status-empty"> │
│ No fetch results have been recorded yet. Run `ookstats fetch cm` │
│ first. │
│ </p> │
│ ) : ( │
│ regionEntries.map(([region, realms]) => { │
│ const latest = latestPeriodByRegion[region] ?? null; │
│ return ( │
│ <details │
│ class="region-section" │
│ data-region={region.toLowerCase()} │
│ > │
│ <summary class="region-summary"> │
│ <span>{region}</span> │
│ {latest !== null && ( │
│ <span class="region-summary__latest"> │
│ Latest period: {latest} │
│ </span> │
│ )} │
│ </summary> │
│ <div class="region-grid"> │
│ {realms.map((realm) => ( │
│ <StatusRealmContainer │
│ realm={realm} │
│ healthLabels={healthLabels} │
│ formatList={formatList} │
│ latestPeriod={latest} │
│ /> │
│ ))} │
│ </div> │
│ </details> │
│ ); │
│ }) │
│ ) │
│ } │
│ </div> │
│ </main> │
│ </PageLayout> │
│ │
│ <style> │
│ .leaderboard-page { │
│ max-width: 1200px; │
│ margin: 0 auto; │
│ padding: 20px; │
│ } │
│ │
│ .status-page__title { │
│ margin-top: 0; │
│ } │
│ │
│ @media (max-width: 768px) { │
│ .leaderboard-page { │
│ padding: 15px; │
│ } │
│ } │
│ </style> │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ASTRO ──────────────────────────────┐
│ --- │
│ import Callout from "../../components/Callou │
│ t/Callout.astro"; │
│ import PageLayout from "../../layouts/PageLa │
│ yout.astro"; │
│ import PlayerSearch from "../../components/P │
│ layerSearch/PlayerSearch.astro"; │
│ import "../../styles/global.scss"; │
│ import "../../components/Status/StatusRunsTa │
│ ble/StatusRunsTable.scss"; │
│ import "../../components/Leaderboard/Leaderb │
│ oardHeader/LeaderboardHeader.scss"; │
│ import type { │
│ CoverageHealth, │
│ RealmCoverage, │
│ StatusApiResponse, │
│ } from "../../lib/types"; │
│ import { readFile } from "node:fs/promises"; │
│ import { join } from "node:path"; │
│ import StatusRealmContainer from "../../comp │
│ onents/Status/StatusRealmContainer/StatusRea │
│ lmContainer.astro"; │
│ import LeaderboardTypeNav from "../../compon │
│ ents/Leaderboard/LeaderboardTypeNav/Leaderbo │
│ ardTypeNav.astro"; │
│ │
│ const filePath = join( │
│ process.cwd(), │
│ "public", │
│ "api", │
│ "status", │
│ "latest-runs.json", │
│ ); │
│ const fileContent = await readFile(filePath, │
│ "utf-8"); │
│ const data = JSON.parse(fileContent) as Stat │
│ usApiResponse; │
│ const realms = Array.isArray(data.realms) ? │
│ data.realms : []; │
│ │
│ const healthLabels: Record<CoverageHealth, s │
│ tring> = { │
│ ok: "OK", │
│ some_missing: "Some missing", │
│ no_data: "No data", │
│ }; │
│ │
│ const formatList = (items?: number[]) => │
│ items && items.length ? items.join(", ") : │
│ "None"; │
│ │
│ const latestPeriodByRegion = realms.reduce<R │
│ ecord<string, number | null>>( │
│ (acc, realm) => { │
│ const regionKey = realm.region.toUpperCa │
│ se(); │
│ let currentMax = acc[regionKey] ?? null; │
│ realm.dungeons.forEach((dungeon) => { │
│ (dungeon.periods || []).forEach((perio │
│ d) => { │
│ if (currentMax === null || period > │
│ currentMax) { │
│ currentMax = period; │
│ } │
│ }); │
│ }); │
│ acc[regionKey] = currentMax; │
│ return acc; │
│ }, │
│ {}, │
│ ); │
│ │
│ const realmsByRegion = realms.reduce<Record< │
│ string, RealmCoverage[]>>( │
│ (acc, realm) => { │
│ const regionKey = realm.region.toUpperCa │
│ se(); │
│ if (!acc[regionKey]) { │
│ acc[regionKey] = []; │
│ } │
│ acc[regionKey].push(realm); │
│ acc[regionKey].sort((a, b) => a.realm_na │
│ me.localeCompare(b.realm_name)); │
│ return acc; │
│ }, │
│ {}, │
│ ); │
│ │
│ const regionEntries = Object.entries(realmsB │
│ yRegion).sort((a, b) => │
│ a[0].localeCompare(b[0]), │
│ ); │
│ --- │
│ │
│ <PageLayout title="Challenge Mode Status"> │
│ <main class="leaderboard-page"> │
│ <h1 class="leaderboard-header status-pag │
│ e__title"> │
│ <span class="header-text">Challenge Mo │
│ de Fetch Status</span> │
│ </h1> │
│ <PlayerSearch /> │
│ <LeaderboardTypeNav currentTab="status" │
│ /> │
│ │
│ <Callout type="note"> │
│ <p> │
│ Periods refer to one week long inter │
│ vals within a challenge mode season. │
│ </p> │
│ </Callout> │
│ │
│ <div class="status-content"> │
│ { │
│ regionEntries.length === 0 ? ( │
│ <p class="status-empty"> │
│ No fetch results have been recor │
│ ded yet. Run `ookstats fetch cm` │
│ first. │
│ </p> │
│ ) : ( │
│ regionEntries.map(([region, realms │
│ ]) => { │
│ const latest = latestPeriodByReg │
│ ion[region] ?? null; │
│ return ( │
│ <details │
│ class="region-section" │
│ data-region={region.toLowerC │
│ ase()} │
│ > │
│ <summary class="region-summa │
│ ry"> │
│ <span>{region}</span> │
│ {latest !== null && ( │
│ <span class="region-summ │
│ ary__latest"> │
│ Latest period: {latest │
│ } │
│ </span> │
│ )} │
│ </summary> │
│ <div class="region-grid"> │
│ {realms.map((realm) => ( │
│ <StatusRealmContainer │
│ realm={realm} │
│ healthLabels={healthLa │
│ bels} │
│ formatList={formatList │
│ } │
│ latestPeriod={latest} │
│ /> │
│ ))} │
│ </div> │
│ </details> │
│ ); │
│ }) │
│ ) │
│ } │
│ </div> │
│ </main> │
│ </PageLayout> │
│ │
│ <style> │
│ .leaderboard-page { │
│ max-width: 1200px; │
│ margin: 0 auto; │
│ padding: 20px; │
│ } │
│ │
│ .status-page__title { │
│ margin-top: 0; │
│ } │
│ │
│ @media (max-width: 768px) { │
│ .leaderboard-page { │
│ padding: 15px; │
│ } │
│ } │
│ </style> │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET