From ab076a92c8a954f0a2bf89161e639dad31abb6d5 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Mon, 27 Apr 2026 20:41:28 +0800 Subject: [PATCH] refactor: remove broken Community Trust chart (TrustBar) - Remove TrustBar component and chart - Remove trust data from game-stats API response - Remove trust section from game detail page - DB columns and vote endpoints preserved for future voting system --- app/game/[id]/game-page-client.tsx | 21 +----- components/charts/TrustBar.tsx | 102 ----------------------------- lib/api/game-stats.ts | 15 +---- 3 files changed, 2 insertions(+), 136 deletions(-) delete mode 100644 components/charts/TrustBar.tsx diff --git a/app/game/[id]/game-page-client.tsx b/app/game/[id]/game-page-client.tsx index 906d2f1..0ba9609 100644 --- a/app/game/[id]/game-page-client.tsx +++ b/app/game/[id]/game-page-client.tsx @@ -31,7 +31,6 @@ import { UpscalerBarChart } from "@/components/charts/UpscalerBarChart" import { FpsBoxplot } from "@/components/charts/FpsBoxplot" import { FpsRangeChart } from "@/components/charts/FpsRangeChart" import { DeviceDonut } from "@/components/charts/DeviceDonut" -import { TrustBar } from "@/components/charts/TrustBar" // Types interface Game { @@ -140,15 +139,6 @@ interface StatsResponse { hardwareName: string count: number }> - trust: Array<{ - id: string - hardwareSlug: string - upvotes: number - downvotes: number - verifiedAt: string | null - userNotes: string | null - createdAt: string - }> filterOptions: { protonVersions: string[] osVersions: string[] @@ -323,7 +313,6 @@ export function GamePageClient({ upscalerStats: filterUpscaler(stats.upscalerStats), fpsRange: filterByDevice(stats.fpsRange), deviceBreakdown: filterByDevice(stats.deviceBreakdown), - trust: filterByDevice(stats.trust), } }, [stats, selectedDevices, filters]) @@ -388,6 +377,7 @@ export function GamePageClient({ className='object-cover' priority onError={handleImgError} + loading="eager" /> ) : (
@@ -990,15 +980,6 @@ export function GamePageClient({
)} - {/* Row 4 — Trust Bar */} - {filteredStats && filteredStats.trust.length > 0 && ( -
-

- Community Trust -

- -
- )} diff --git a/components/charts/TrustBar.tsx b/components/charts/TrustBar.tsx deleted file mode 100644 index cb588df..0000000 --- a/components/charts/TrustBar.tsx +++ /dev/null @@ -1,102 +0,0 @@ -"use client" - -import { useMemo } from "react" -import { EChartWrapper, CHART_THEME } from "./EChartWrapper" -import type { EChartsOption } from "echarts" - -interface TrustEntry { - id: string - hardwareSlug: string - upvotes: number - downvotes: number - verifiedAt: string | null - userNotes: string | null - createdAt: string -} - -export function TrustBar({ - data, - className, -}: { - data: TrustEntry[] - className?: string -}) { - const option = useMemo(() => { - const sorted = [...data] - .sort((a, b) => b.upvotes - b.downvotes - (a.upvotes - a.downvotes)) - .slice(0, 20) - - const labels = sorted.map((e) => { - const date = new Date(e.createdAt).toLocaleDateString("en-US", { - month: "short", - day: "numeric", - }) - return e.userNotes - ? `${e.userNotes.slice(0, 20)}...` - : `Entry ${date}` - }) - - const scores = sorted.map((e) => e.upvotes - e.downvotes) - - return { - tooltip: { - trigger: "axis", - backgroundColor: "#1a1025", - borderColor: CHART_THEME.border, - textStyle: { color: CHART_THEME.text, fontSize: 12 }, - formatter: (params) => { - const p = Array.isArray(params) ? params[0] : null - if (!p) return "" - const idx = (p as { dataIndex: number }).dataIndex - const entry = sorted[idx] - if (!entry) return "" - return `↑${entry.upvotes} ↓${entry.downvotes}${entry.verifiedAt ? " ✅ Verified" : ""}` - }, - }, - grid: { top: 8, right: 16, bottom: 8, left: 120 }, - xAxis: { - type: "value", - axisLabel: { color: CHART_THEME.textMuted, fontSize: 10 }, - splitLine: { lineStyle: { color: CHART_THEME.border, opacity: 0.3 } }, - }, - yAxis: { - type: "category", - data: labels, - inverse: true, - axisLabel: { - color: CHART_THEME.textMuted, - fontSize: 10, - width: 100, - overflow: "truncate", - }, - axisLine: { show: false }, - axisTick: { show: false }, - }, - series: [ - { - type: "bar", - data: scores.map((score, idx) => ({ - value: score, - itemStyle: { - color: sorted[idx].verifiedAt - ? CHART_THEME.success - : CHART_THEME.textSubtle, - borderRadius: [0, 4, 4, 0], - }, - })), - barWidth: "60%", - }, - ], - } - }, [data]) - - if (data.length === 0) return null - - return ( - - ) -} diff --git a/lib/api/game-stats.ts b/lib/api/game-stats.ts index a421885..82e154b 100644 --- a/lib/api/game-stats.ts +++ b/lib/api/game-stats.ts @@ -74,7 +74,6 @@ export const gameStatsRoutes = new Elysia({ prefix: "/games" }).get( upscalerStats: [], fpsRange: [], deviceBreakdown: [], - trust: [], filterOptions: { protonVersions: [], osVersions: [] }, } } @@ -239,18 +238,7 @@ export const gameStatsRoutes = new Elysia({ prefix: "/games" }).get( }), ) - // ── 9. Community trust ──────────────────────────────────────── - const trust = entries.map((e) => ({ - id: e.id, - hardwareSlug: e.hardwareSlug, - upvotes: e.upvotes, - downvotes: e.downvotes, - verifiedAt: e.verifiedAt ? e.verifiedAt.toISOString() : null, - userNotes: e.userNotes, - createdAt: e.createdAt.toISOString(), - })) - - // ── 10. Filter options ──────────────────────────────────────── + // ── 9. Filter options ──────────────────────────────────────── const protonVersions = [ ...new Set(entries.map((e) => e.protonVersion).filter(Boolean)), ] as string[] @@ -273,7 +261,6 @@ export const gameStatsRoutes = new Elysia({ prefix: "/games" }).get( upscalerStats, fpsRange, deviceBreakdown, - trust, filterOptions: { protonVersions, osVersions }, } },