11---
22import Page from ' @/layouts/Page.astro' ;
3- import Summary from ' @/components/Summary .astro' ;
3+ import MetricsSection from ' @/components/MetricsSection .astro' ;
44import ScreenshotDisplay from ' @/components/ScreenshotDisplay.astro' ;
55import TestInfoPanel from ' @/components/TestInfoPanel.astro' ;
66import Tabs from ' @/components/Tabs.astro' ;
77import AllMetrics from ' @/components/AllMetrics.astro' ;
88
99import { getPrismaClient } from ' @/lib/prisma/client' ;
10- import { getTestById , getTestRating } from ' @/lib/repositories/testRepository ' ;
11- import { ContentRating } from ' @/generated/prisma/client ' ;
10+ import { getTestById } from ' @/lib/repositories/test-repository ' ;
11+ import { ContentRating } from ' @/lib/classes/TestConfig ' ;
1212
13- import type { MetricsJson } from ' @/lib/types/results ' ;
13+ import type { MetricsJson } from ' @/lib/metrics/types ' ;
1414import {
1515 extractFcp ,
1616 extractLcp ,
@@ -24,7 +24,7 @@ import {
2424 getLcpRating ,
2525 getClsRating ,
2626 getTtfbRating ,
27- } from ' @/lib/metrics/ratings ' ;
27+ } from ' @/lib/metrics/web-vitals ' ;
2828import { formatMs , formatDecimal , formatKb } from ' @/lib/metrics/formatters' ;
2929
3030export const prerender = false ;
@@ -43,14 +43,9 @@ if (!test) {
4343 return Astro .redirect (' /results' );
4444}
4545
46- const rating = await getTestRating (prisma , testId );
47- if (rating === null ) {
48- return Astro .redirect (' /results' );
49- }
50-
5146// When AI rating is disabled, treat everything as safe
52- const isUnknown = aiEnabled && (test .rating === ContentRating .UNKNOWN || test .rating === ContentRating .IN_PROGRESS );
53- const isUnsafe = aiEnabled && test .rating === ContentRating .UNSAFE ;
47+ const isUnknown = aiEnabled && (test .content_rating === ContentRating .UNKNOWN || test .content_rating === ContentRating .IN_PROGRESS );
48+ const isUnsafe = aiEnabled && test .content_rating === ContentRating .UNSAFE ;
5449
5550
5651// --- Screenshot ---
@@ -135,8 +130,7 @@ const formattedDate = date.toLocaleString('en-US', {
135130 </div >
136131 )}
137132
138-
139- { ! isUnsafe && (
133+ { ! isUnsafe && ! isUnknown && (
140134 <>
141135 <div class = " title-section" >
142136 { test .name ? <h1 >{ test .name } </h1 > : <h1 >{ test .test_id } </h1 >}
@@ -240,8 +234,7 @@ const formattedDate = date.toLocaleString('en-US', {
240234 const res = await fetch(`/api/tests/${testId}/rating`);
241235 const data: { rating: string } = await res.json();
242236 if (data.rating === 'safe') {
243- if (pendingBanner) pendingBanner.style.display = 'none';
244- if (testContent) testContent.style.display = '';
237+ window.location.reload();
245238 return;
246239 }
247240 if (data.rating === 'unsafe') {
0 commit comments