-
Notifications
You must be signed in to change notification settings - Fork 0
Assessment: L1 Eliminatory filters, Post-Processing & Results page #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vprashrex
wants to merge
6
commits into
dev
Choose a base branch
from
feat/assessment-pipeline-l1
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c726a61
Chore: Enhance spreadsheet state management with debouncing and schem…
vprashrex 3fa5056
Chore: Define SpreadsheetStateEnvelope type for improved state manage…
vprashrex 0529981
feat: Enhance assessment configuration and saved config cards with la…
vprashrex f456db7
Merge branch 'dev' into feat/assessment-pipeline-l1
vprashrex d459985
feat: Implement CSV download functionality and enhance DownloadDropdo…
vprashrex cbb0016
feat: add pre-filtering capabilities to assessment runs
vprashrex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import { useParams, useSearchParams } from "next/navigation"; | ||
| import dynamic from "next/dynamic"; | ||
| import Loader from "@/app/components/Loader"; | ||
| import { useToast } from "@/app/components/Toast"; | ||
| import { useAuth } from "@/app/lib/context/AuthContext"; | ||
| import { apiFetch } from "@/app/lib/apiClient"; | ||
| import { jsonResultsToTableData } from "@/app/lib/assessment/results"; | ||
| import { SPREADSHEET_PREVIEW_ROW_LIMIT } from "@/app/lib/assessment/constants"; | ||
|
|
||
| const SpreadsheetView = dynamic( | ||
| () => import("@/app/components/assessment/SpreadsheetView"), | ||
| { | ||
| ssr: false, | ||
| loading: () => ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <Loader size="lg" message="Loading spreadsheet..." /> | ||
| </div> | ||
| ), | ||
| }, | ||
| ); | ||
|
|
||
| export default function AssessmentResultsPage() { | ||
| const params = useParams<{ runId: string }>(); | ||
| const searchParams = useSearchParams(); | ||
| const toast = useToast(); | ||
| const { apiKeys, isAuthenticated, isHydrated } = useAuth(); | ||
| const apiKey = apiKeys[0]?.key ?? ""; | ||
|
|
||
| const runId = Number(params?.runId); | ||
| const title = searchParams.get("title") ?? `Run ${runId}`; | ||
|
|
||
| const [headers, setHeaders] = useState<string[] | null>(null); | ||
| const [rows, setRows] = useState<string[][] | null>(null); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!isHydrated) return; | ||
| if (!isAuthenticated) { | ||
| setError("You must be signed in to view this run."); | ||
| return; | ||
| } | ||
| if (!Number.isFinite(runId) || runId <= 0) { | ||
| setError("Invalid run id."); | ||
| return; | ||
| } | ||
|
|
||
| let cancelled = false; | ||
| (async () => { | ||
| try { | ||
| const json = await apiFetch< | ||
| { data?: Record<string, unknown>[] } | Record<string, unknown>[] | ||
| >(`/api/assessment/runs/${runId}/results?export_format=json`, apiKey); | ||
| const results: Record<string, unknown>[] = Array.isArray(json) | ||
| ? json | ||
| : json.data || []; | ||
| const table = jsonResultsToTableData(results, { | ||
| rowLimit: SPREADSHEET_PREVIEW_ROW_LIMIT, | ||
| }); | ||
| if (cancelled) return; | ||
| if (results.length > SPREADSHEET_PREVIEW_ROW_LIMIT) { | ||
| toast.warning( | ||
| `Preview capped at ${SPREADSHEET_PREVIEW_ROW_LIMIT} rows. Download CSV for full data.`, | ||
| ); | ||
| } | ||
| setHeaders(table.headers); | ||
| setRows(table.rows); | ||
| } catch (err) { | ||
| if (cancelled) return; | ||
| const msg = | ||
| err instanceof Error ? err.message : "Failed to load results"; | ||
| setError(msg); | ||
| toast.error(msg); | ||
| } | ||
| })(); | ||
|
|
||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, [apiKey, isAuthenticated, isHydrated, runId, toast]); | ||
|
|
||
| if (error) { | ||
| return ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <p className="text-sm text-text-secondary">{error}</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (!headers || !rows) { | ||
| return ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <Loader size="lg" message="Loading results..." /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <SpreadsheetView | ||
| runId={runId} | ||
| title={title} | ||
| subtitle={`${rows.length} rows · ${headers.length} columns`} | ||
| headers={headers} | ||
| rows={rows} | ||
| /> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // BFF proxy — POST /api/v1/assessment/runs/:id/resume | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { apiClient } from "@/app/lib/apiClient"; | ||
| import type { RouteContext } from "@/app/lib/types/assessment"; | ||
|
|
||
| export async function POST( | ||
| request: NextRequest, | ||
| context: RouteContext<"run_id">, | ||
| ) { | ||
| try { | ||
| const { run_id } = await context.params; | ||
| const { status, data } = await apiClient( | ||
| request, | ||
| `/api/v1/assessment/runs/${run_id}/resume`, | ||
| { method: "POST" }, | ||
| ); | ||
|
|
||
| return NextResponse.json(data, { status }); | ||
| } catch (error: unknown) { | ||
| console.error("Assessment run resume proxy error:", error); | ||
| return NextResponse.json( | ||
| { | ||
| error: "Failed to forward assessment run resume request", | ||
| }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these useState related hooks calling above of the runId.