diff --git a/src/app/(app)/problems/[id]/layout.tsx b/src/app/(app)/problems/[problemId]/layout.tsx similarity index 80% rename from src/app/(app)/problems/[id]/layout.tsx rename to src/app/(app)/problems/[problemId]/layout.tsx index 8ed15e9..c82780b 100644 --- a/src/app/(app)/problems/[id]/layout.tsx +++ b/src/app/(app)/problems/[problemId]/layout.tsx @@ -3,16 +3,16 @@ import { ProblemHeader } from "@/features/problems/components/problem-header"; interface ProblemLayoutProps { children: React.ReactNode; - params: Promise<{ id: string }>; + params: Promise<{ problemId: string }>; } export default async function ProblemLayout({ children, params, }: ProblemLayoutProps) { - const { id } = await params; + const { problemId } = await params; - if (!id) { + if (!problemId) { return notFound(); } diff --git a/src/features/problems/description/components/content.tsx b/src/features/problems/description/components/content.tsx index 2a090ee..fd2885f 100644 --- a/src/features/problems/description/components/content.tsx +++ b/src/features/problems/description/components/content.tsx @@ -4,11 +4,11 @@ import { MdxRenderer } from "@/components/content/mdx-renderer"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; interface DescriptionContentProps { - id: string; + problemId: string; } -const DescriptionContent = async ({ id }: DescriptionContentProps) => { - const problem = await getCachedProblem(id); +const DescriptionContent = async ({ problemId }: DescriptionContentProps) => { + const problem = await getCachedProblem(problemId); return ( diff --git a/src/features/problems/description/components/panel.tsx b/src/features/problems/description/components/panel.tsx index 9ffd4dc..8cdf4aa 100644 --- a/src/features/problems/description/components/panel.tsx +++ b/src/features/problems/description/components/panel.tsx @@ -5,16 +5,16 @@ import { } from "@/features/problems/description/components/content"; interface DescriptionPanelProps { - id: string; + problemId: string; } -const DescriptionPanel = ({ id }: DescriptionPanelProps) => { +const DescriptionPanel = ({ problemId }: DescriptionPanelProps) => { return (
}> - +
diff --git a/src/features/problems/solution/components/content.tsx b/src/features/problems/solution/components/content.tsx index 4a62da2..8c053f5 100644 --- a/src/features/problems/solution/components/content.tsx +++ b/src/features/problems/solution/components/content.tsx @@ -4,11 +4,11 @@ import { MdxRenderer } from "@/components/content/mdx-renderer"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; interface SolutionContentProps { - id: string; + problemId: string; } -const SolutionContent = async ({ id }: SolutionContentProps) => { - const problem = await getCachedProblem(id); +const SolutionContent = async ({ problemId }: SolutionContentProps) => { + const problem = await getCachedProblem(problemId); return ( diff --git a/src/features/problems/solution/components/panel.tsx b/src/features/problems/solution/components/panel.tsx index eba0fcc..a503f13 100644 --- a/src/features/problems/solution/components/panel.tsx +++ b/src/features/problems/solution/components/panel.tsx @@ -5,16 +5,16 @@ import { } from "@/features/problems/solution/components/content"; interface SolutionPanelProps { - id: string; + problemId: string; } -const SolutionPanel = ({ id }: SolutionPanelProps) => { +const SolutionPanel = ({ problemId }: SolutionPanelProps) => { return (
}> - +
diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts index e8ce447..85e69d6 100644 --- a/src/lib/prisma.ts +++ b/src/lib/prisma.ts @@ -61,52 +61,60 @@ export const getCachedProblems = cache( ) ); -const getProblem = async (id: string) => { +const getProblem = async (problemId: string) => { const startTime = Date.now(); - log.debug({ id }, "Fetching single problem"); + log.debug({ problemId }, "Fetching single problem"); try { - const problem = await prisma.problem.findUnique({ where: { id } }); + const problem = await prisma.problem.findUnique({ + where: { id: problemId }, + }); if (problem) { - log.debug({ id, durationMs: Date.now() - startTime }, "Problem found"); + log.debug( + { problemId, durationMs: Date.now() - startTime }, + "Problem found" + ); } else { - log.warn({ id, durationMs: Date.now() - startTime }, "Problem not found"); + log.warn( + { problemId, durationMs: Date.now() - startTime }, + "Problem not found" + ); } return problem; } catch (error) { log.error( - { id, durationMs: Date.now() - startTime, error }, + { problemId, durationMs: Date.now() - startTime, error }, "Failed to fetch problem" ); throw error; } }; -export const getCachedProblem = cache((id: string) => +export const getCachedProblem = cache((problemId: string) => unstable_cache( async () => { const startTime = Date.now(); log.debug( - { id }, + { problemId }, "Calling getProblemCached (expect cache hit if warmed)" ); try { - const result = await getProblem(id); + const result = await getProblem(problemId); log.info( - { id, durationMs: Date.now() - startTime }, + { problemId, durationMs: Date.now() - startTime }, "getProblemCached finished" ); return result; } catch (error) { log.error( - { id, durationMs: Date.now() - startTime, error }, + { problemId, durationMs: Date.now() - startTime, error }, "getProblemCached failed" ); throw error; } }, - ["getProblem", id], + ["getProblem", problemId], { - tags: [`problem-${id}`], + tags: [`problem-${problemId}`], } )() );