problem refrencing in live runs

This commit is contained in:
2026-02-07 22:22:41 +01:00
parent 2f55f3b3fb
commit bfd2ce5719
3 changed files with 21 additions and 7 deletions
+15 -1
View File
@@ -5,6 +5,10 @@ import { TableRow, TableCell } from "@/components/ui/table";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { LiveRun } from "@/modules/live-run/types"; import { LiveRun } from "@/modules/live-run/types";
import formatTime from "@/lib/time-format"; import formatTime from "@/lib/time-format";
import useAction from "@/hook/use-action";
import { getProblem } from "@/modules/problems/actions";
import Link from "next/link";
import { LinkIcon } from "lucide-react";
export default function LiveRunRow({ export default function LiveRunRow({
index, index,
@@ -13,6 +17,8 @@ export default function LiveRunRow({
index: number; index: number;
run: LiveRun; run: LiveRun;
}) { }) {
const [problem] = useAction(() => getProblem(run.problem));
const now = new Date().getTime() + 1000; const now = new Date().getTime() + 1000;
const isTop = run.views > 5; const isTop = run.views > 5;
@@ -33,7 +39,15 @@ export default function LiveRunRow({
</TableCell> </TableCell>
{/* Problem + Category */} {/* Problem + Category */}
<TableCell>{run.problem}</TableCell> <TableCell>
<Link
href={`problems/${run.problem}`}
className="hover:text-primary flex items-center gap-1"
>
<LinkIcon className="w-3 h-3" />
{problem?.title || run.problem}
</Link>
</TableCell>
{/* Runtime */} {/* Runtime */}
<TableCell <TableCell
+4 -4
View File
@@ -14,7 +14,7 @@ export async function getLiveRuns(): Promise<LiveRun[]> {
{ {
id: "1", id: "1",
username: "speedmaster_x", username: "speedmaster_x",
problem: "Two Sum Dash", problem: "fix-auth-callback",
category: "any%", category: "any%",
views: 670, views: 670,
runsCount: 1, runsCount: 1,
@@ -24,7 +24,7 @@ export async function getLiveRuns(): Promise<LiveRun[]> {
id: "2", id: "2",
username: "algo_ninja", username: "algo_ninja",
views: 3, views: 3,
problem: "Binary Sprint", problem: "fix-prod-build",
category: "any%", category: "any%",
runsCount: 1, runsCount: 1,
start: new Date().getTime(), start: new Date().getTime(),
@@ -33,14 +33,14 @@ export async function getLiveRuns(): Promise<LiveRun[]> {
id: "3", id: "3",
username: "stackattack", username: "stackattack",
views: 3, views: 3,
problem: "String Scramble", problem: "add-user-profile-endpoint",
category: "any%", category: "any%",
runsCount: 1, runsCount: 1,
start: new Date().getTime(), start: new Date().getTime(),
}, },
{ {
id: "4", id: "4",
username: "reset_king", username: "fix-prod-build",
views: 3, views: 3,
problem: "Linked List Rush", problem: "Linked List Rush",
category: "any%", category: "any%",
+2 -2
View File
@@ -20,7 +20,7 @@ const problems: ProblemDefinition[] = [
description: description:
"Production build fails while development works. Fix the build.", "Production build fails while development works. Fix the build.",
language: "javascript", language: "javascript",
difficulty: "easy", difficulty: "hard",
validate100: () => true, validate100: () => true,
validateAny: () => true, validateAny: () => true,
}, },
@@ -29,7 +29,7 @@ const problems: ProblemDefinition[] = [
title: "Implement Missing API Endpoint", title: "Implement Missing API Endpoint",
description: "The frontend expects `/api/me`. Implement it correctly.", description: "The frontend expects `/api/me`. Implement it correctly.",
language: "go", language: "go",
difficulty: "easy", difficulty: "medium",
validate100: () => true, validate100: () => true,
validateAny: () => true, validateAny: () => true,
}, },