PageSourceSearch

https://gridiron-oracle-support1415.replit.app/assets/accuracy-tracking-DBnaXgf8.js

js gridiron-oracle-support1415.replit.app collected 2026-10-03 03:54:25 UTC 11,232 bytes, 1 lines download raw bytes

1import{g as T,u as w,j as e,B as F,R as L,ab as U,C as l,e as o,b as f,c as g,q as b,s as W}from"./index-B4Lgdz8g.js";import{u as q}from"./useMutation-BvSeUyC4.js";import{A as M,b as R,a as D}from"./alert-Dhwhc0WP.js";const A=W();function Q(){const{toast:j}=T(),m=new Date().getFullYear(),{data:i,isLoading:C}=w({queryKey:["/api/accuracy"]});i==null||i.data;const{data:n=[],isLoading:k}=w({queryKey:["/api/accuracy/weekly",m],queryFn:async()=>{const s=[];for(let t=1;t<=18;t++)try{const r=await A(`/api/accuracy/week/${t}/season/${m}`);if(r.ok){const c=await r.json();c.totalPredictions>0&&s.push(c)}}catch{}return s.sort((t,r)=>t.week-r.week)}}),u=q({mutationFn:async()=>{const s=new Date().getFullYear(),t=[];for(let r=1;r<=18;r++)try{const c=await A(`/api/accuracy/refresh/week/${r}/season/${s}`,{method:"POST"});if(c.ok){const a=await c.json();a.updatedPredictions>0&&t.push({week:r,...a})}}catch{console.log(`No data for week ${r}, skipping...`)}return t},onSuccess:s=>{b.invalidateQueries({queryKey:["/api/accuracy"]}),b.invalidateQueries({queryKey:["/api/accuracy/weekly",m]});const t=s.reduce((r,c)=>r+(c.updatedPredictions||0),0);j({title:"Accuracy Refreshed",description:`Updated ${t} predictions across ${s.length} weeks`})},onError:s=>{j({title:"Refresh Failed",description:(s==null?void 0:s.message)||"Failed to refresh accuracy data. Please try again.",variant:"destructive"})}});if(C||k)return e.jsx("div",{className:"p-6",children:"Loading accuracy metrics..."});const h=n.reduce((s,t)=>s+t.totalPredictions,0),y=n.reduce((s,t)=>s+t.straightUp.wins,0),P=h>0?y/h*100:0,S=n.flatMap(s=>s.confidenceCalibration.buckets),x=["50-60%","60-70%","70-80%","80-90%","90-100%"].map(s=>{const t=S.filter(d=>d.range===s),r=t.reduce((d,p)=>d+p.predictions,0),c=t.reduce((d,p)=>d+p.correctPredictions,0),a=r>0?c/r*100:0;return{range:s,predictions:r,accuracy:Math.round(a)}}),$=n.reduce((s,t)=>s+t.againstTheSpread.wins,0),N=n.reduce((s,t)=>s+t.againstTheSpread.gamesWithSpreads,0),v=N>0?$/N*100:0;return e.jsxs("div",{className:"flex-1 overflow-auto",children:[e.jsx("header",{className:"bg-card border-b border-border px-3 sm:px-6 py-3 sm:py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Accuracy Tracking"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor prediction model performance over time"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>u.mutate(),disabled:u.isPending,"data-testid":"button-refresh-all-accuracy",className:"flex items-center gap-2",children:[e.jsx(L,{className:`h-4 w-4 ${u.isPending?"animate-spin":""}`}),e.jsx("span",{children:"Refresh All"})]})})]})}),e.jsxs("div",{className:"p-3 sm:p-6 space-y-4 sm:space-y-6",children:[(i==null?void 0:i.purgedAt)&&e.jsxs(M,{variant:"default",className:"border-yellow-500 bg-yellow-50 dark:bg-yellow-950","data-testid":"alert-accuracy-purged",children:[e.jsx(U,{className:"h-4 w-4 text-yellow-600"}),e.jsx(R,{className:"text-yellow-800 dark:text-yellow-200",children:"Stored accuracy rows were cleared"}),e.jsxs(D,{className:"text-yellow-700 dark:text-yellow-300",children:["The ",e.jsx("code",{children:"accuracy_metrics"})," table was intentionally purged on"," ",new Date(i.purgedAt).toLocaleString()," to remove incorrect tie-as-loss counts. Live per-week accuracy is still available below via"," ",e.jsx("code",{children:"/api/accuracy/week/:week/season/:season"}),"."]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(l,{children:e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-foreground","data-testid":"text-overall-accuracy",children:[P.toFixed(1),"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Overall Accuracy"})]})})}),e.jsx(l,{children:e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-foreground",children:h}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Predictions"})]})})}),e.jsx(l,{children:e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-foreground",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Correct Predictions"})]})})})]}),e.jsxs(l,{children:[e.jsxs(f,{children:[e.jsx(g,{children:"Weekly Accuracy Trend"}),e.jsx("p",{className:"text-muted-foreground",children:"Prediction accuracy by week"})]}),e.jsx(o,{children:e.jsx("div",{className:"space-y-6",children:n.length===0?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"No weekly data available yet. Check back after games are completed."}):n.map(s=>{var r;const t=c=>c>=80?"bg-green-600":c>=70?"bg-yellow-600":"bg-red-600";return e.jsxs("div",{className:"space-y-3","data-testid":`row-week-${s.week}`,children:[e.jsxs("div",{className:"font-medium text-foreground",children:["Week ",s.week]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-24",children:"Straight Up"}),e.jsx("div",{className:"flex-1 bg-muted rounded-full h-3 max-w-md",children:e.jsx("div",{className:`h-3 rounded-full ${t(s.straightUp.accuracy)}`,style:{width:`${s.straightUp.accuracy}%`}})})]}),e.jsxs("div",{className:"flex items-center space-x-6 text-sm ml-4",children:[e.jsxs("span",{className:"font-medium",children:[s.straightUp.accuracy.toFixed(1),"%"]}),e.jsxs("span",{className:"text-muted-foreground",children:[s.straightUp.wins,"/",s.totalPredictions]})]})]}),((r=s.againstTheSpread)==null?void 0:r.gamesWithSpreads)>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-24",children:"Against Spread"}),e.jsx("div",{className:"flex-1 bg-muted rounded-full h-3 max-w-md",children:e.jsx("div",{className:`h-3 rounded-full ${t(s.againstTheSpread.accuracy)}`,style:{width:`${s.againstTheSpread.accuracy}%`}})})]}),e.jsxs("div",{className:"flex items-center space-x-6 text-sm ml-4",children:[e.jsxs("span",{className:"font-medium",children:[s.againstTheSpread.accuracy.toFixed(1),"%"]}),e.jsxs("span",{className:"text-muted-foreground",children:[s.againstTheSpread.wins,"/",s.againstTheSpread.gamesWithSpreads]})]})]})]},s.week)})})})]}),e.jsxs(l,{children:[e.jsxs(f,{children:[e.jsx(g,{children:"Confidence vs Accuracy"}),e.jsx("p",{className:"text-muted-foreground",children:"How prediction confidence correlates with actual accuracy"})]}),e.jsx(o,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:x.length===0?e.jsx("div",{className:"col-span-3 text-center py-4 text-muted-foreground",children:"No confidence data available yet."}):e.jsxs(e.Fragment,{children:[(()=>{const s=x.filter(a=>a.range==="70-80%"||a.range==="80-90%"||a.range==="90-100%"),t=s.reduce((a,d)=>a+d.predictions,0),r=t>0?Math.round(s.reduce((a,d)=>a+d.accuracy*d.predictions,0)/t):0,c=a=>a>=80?"text-green-600":a>=65?"text-yellow-600":"text-red-600";return e.jsxs("div",{className:"text-center p-4 border border-border rounded-lg",children:[e.jsxs("p",{className:`text-2xl font-bold ${c(r)}`,children:[r,"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"High Confidence (≥70%)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t," predictions"]})]})})(),(()=>{const s=x.find(a=>a.range==="60-70%"),t=(s==null?void 0:s.accuracy)||0,r=(s==null?void 0:s.predictions)||0,c=a=>a>=80?"text-green-600":a>=65?"text-yellow-600":"text-red-600";return e.jsxs("div",{className:"text-center p-4 border border-border rounded-lg",children:[e.jsxs("p",{className:`text-2xl font-bold ${c(t)}`,children:[t,"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Medium Confidence (60-70%)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r," predictions"]})]})})(),(()=>{const s=x.find(a=>a.range==="50-60%"),t=(s==null?void 0:s.accuracy)||0,r=(s==null?void 0:s.predictions)||0,c=a=>a>=80?"text-green-600":a>=65?"text-yellow-600":"text-red-600";return e.jsxs("div",{className:"text-center p-4 border border-border rounded-lg",children:[e.jsxs("p",{className:`text-2xl font-bold ${c(t)}`,children:[t,"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Low Confidence (50-60%)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r," predictions"]})]})})()]})})})]}),e.jsxs(l,{children:[e.jsxs(f,{children:[e.jsx(g,{children:"Performance Summary"}),e.jsx("p",{className:"text-muted-foreground",children:"Key metrics from your NFL prediction model"})]}),e.jsx(o,{children:e.jsx("div",{className:"space-y-4",children:n.length===0?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"Performance metrics will appear after predictions are evaluated."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Against the Spread Performance"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Success rate vs Vegas betting lines"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"bg-muted rounded-full h-2 w-24",children:e.jsx("div",{className:"bg-primary h-2 rounded-full",style:{width:`${v}%`}})}),e.jsxs("span",{className:"text-sm font-medium w-12",children:[v.toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Average Confidence Level"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"AI model confidence in predictions"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"bg-muted rounded-full h-2 w-24",children:(()=>{const s=n.reduce((t,r)=>t+r.confidenceCalibration.averageConfidence,0)/n.length;return e.jsx("div",{className:"bg-primary h-2 rounded-full",style:{width:`${s}%`}})})()}),e.jsxs("span",{className:"text-sm font-medium w-12",children:[(n.reduce((s,t)=>s+t.confidenceCalibration.averageConfidence,0)/n.length).toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Weeks Analyzed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"NFL weeks with completed predictions"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"bg-muted rounded-full h-2 w-24",children:e.jsx("div",{className:"bg-primary h-2 rounded-full",style:{width:`${n.length/18*100}%`}})}),e.jsxs("span",{className:"text-sm font-medium w-12",children:[n.length,"/18"]})]})]})]})})})]})]})]})}export{Q as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.