1import{j as e}from"./markdown-B-XC8faE.js";import{r as d,I as C,l as I,j as L,T as R}from"./icons-FOYoml-d.js";import{l as F,s as u,e as N,H as v,I as w,B as _}from"./index-CnEchNE5.js";import{L as k}from"./label-dBcUM3G2.js";import{A as T}from"./AdminNav-Cit4RV9G.js";import{h as $,f as y}from"./timeFormat-Bm9GVZ4x.js";import"./three-CWrCzQay.js";import"./radix-CZPgPwSx.js";import"./supabase-DRo1YIZv.js";import"./motion-Bqrfl3ZR.js";function M(a){if(!a)return"never";const n=Date.now()-new Date(a).getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";const l=Math.floor(r/60),h=Math.floor(l/24);return h>0?`${h}d ${l%24}h ago`:l>0?`${l}h ${r%60}m ago`:`${r}m ago`}function O(a){if(!a)return"â";const n=new Date(a).getTime()-Date.now();if(n<0)return"due";const r=Math.floor(n/6e4),l=Math.floor(r/60);return l===0?`in ${r}m`:`in ${l}h ${r%60}m`}function q(a,n){return a?a==="succeeded"&&n===0?{label:"OK",cls:"bg-black text-white"}:a==="succeeded"&&n>0?{label:"DEGRADED",cls:"bg-white text-black border-2 border-black"}:{label:"FAILED",cls:"bg-white text-black border-2 border-black underline"}:{label:"NO RUNS",cls:"bg-white text-black border-2 border-black"}}const V=()=>{const{toast:a}=F(),[n,r]=d.useState(!1),[l,h]=d.useState(!1),[b,S]=d.useState(""),[j,A]=d.useState(""),[f,p]=d.useState(!1);d.useEffect(()=>{u.auth.getSession().then(({data:{session:t}})=>{h(!!t),r(!0)});const{data:s}=u.auth.onAuthStateChange((t,i)=>{h(!!i)});return()=>s.subscription.unsubscribe()},[]);const D=async s=>{s.preventDefault(),p(!0);const{error:t}=await u.auth.signInWithPassword({email:b,password:j});p(!1),t&&a({title:"Login failed",description:t.message,variant:"destructive"})},c=N({queryKey:["schedule-status"],enabled:l,refetchInterval:6e4,queryFn:async()=>{const{data:s,error:t}=await u.rpc("get_cron_job_status");if(t)throw t;return s||[]}}),m=N({queryKey:["schedule-upcoming"],enabled:l,refetchInterval:6e4,queryFn:async()=>{const{data:s,error:t}=await u.rpc("get_upcoming_cron_runs",{hours_ahead:24});if(t)throw t;return s||[]}}),E=d.useMemo(()=>{const s=new Map;return(m.data||[]).forEach(t=>{const i=s.get(t.jobid);(!i||new Date(t.next_run)<new Date(i))&&s.set(t.jobid,t.next_run)}),s},[m.data]),g=d.useMemo(()=>(c.data||[]).slice().sort((s,t)=>s.jobname.localeCompare(t.jobname)),[c.data]),o=d.useMemo(()=>{const s=c.data||[];return{total:s.length,active:s.filter(t=>t.active).length,ok:s.filter(t=>t.last_run_status==="succeeded"&&t.failures_24h===0).length,failed:s.filter(t=>t.failures_24h>0).length,noruns:s.filter(t=>!t.last_run_status).length}},[c.data]);return n?l?e.jsxs("div",{className:"min-h-screen bg-white text-black",children:[e.jsxs(v,{children:[e.jsx("title",{children:"Schedule Status â Admin"}),e.jsx("meta",{name:"robots",content:"noindex,nofollow"})]}),e.jsxs("div",{className:"max-w-7xl mx-auto p-4 md:p-8 space-y-6",children:[e.jsx(T,{}),e.jsxs("header",{className:"border-2 border-black p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold uppercase tracking-tight",children:"Schedule Status"}),e.jsx("p",{className:"text-sm mt-1",children:"Every publishing job, its next run, last run, and 24h success/fail count."})]}),e.jsxs(_,{size:"sm",onClick:()=>{c.refetch(),m.refetch()},className:"rounded-none border-2 border-black",children:[e.jsx(C,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 mt-5 text-xs",children:[e.jsx(x,{label:"JOBS",value:o.total}),e.jsx(x,{label:"ACTIVE",value:o.active}),e.jsx(x,{label:"OK 24H",value:o.ok}),e.jsx(x,{label:"WITH FAILURES",value:o.failed,bold:o.failed>0}),e.jsx(x,{label:"NO RUNS YET",value:o.noruns,bold:o.noruns>0})]})]}),c.isLoading&&e.jsx("div",{className:"border-2 border-black p-6",children:"Loading statusâ¦"}),c.error&&e.jsxs("div",{className:"border-2 border-black p-6 bg-white",children:[e.jsx("strong",{children:"Failed to load:"})," ",c.error.message]}),!c.isLoading&&g.length>0&&e.jsx("div",{className:"border-2 border-black overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-black text-white uppercase text-xs",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Job"}),e.jsx("th",{className:"text-left p-3",children:"Schedule (PT)"}),e.jsx("th",{className:"text-left p-3",children:"Next Run"}),e.jsx("th",{className:"text-left p-3",children:"Last Run"}),e.jsx("th",{className:"text-left p-3",children:"Status"}),e.jsx("th",{className:"text-right p-3",children:"Runs 24h"}),e.jsx("th",{className:"text-right p-3",children:"Fails 24h"})]})}),e.jsx("tbody",{children:g.map(s=>{const t=E.get(s.jobid)||null,i=q(s.last_run_status,s.failures_24h);return e.jsxs("tr",{className:"border-t-2 border-black",children:[e.jsxs("td",{className:"p-3 font-mono text-xs",children:[e.jsx("div",{className:"font-bold",children:s.jobname}),!s.active&&e.jsx("div",{className:"text-[10px] uppercase mt-1",children:"Inactive"})]}),e.jsxs("td",{className:"p-3",children:[e.jsx("div",{children:$(s.schedule)}),e.jsx("div",{className:"font-mono text-[10px] mt-1",children:s.schedule})]}),e.jsx("td",{className:"p-3",children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:y(t)}),e.jsxs("div",{className:"text-xs mt-1 flex items-center gap-1",children:[e.jsx(I,{className:"w-3 h-3"}),O(t)]})]}):e.jsx("span",{className:"text-xs",children:"not in next 24h"})}),e.jsx("td",{className:"p-3",children:s.last_run_at?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:y(s.last_run_at)}),e.jsx("div",{className:"text-xs mt-1",children:M(s.last_run_at)})]}):e.jsx("span",{className:"text-xs",children:"never"})}),e.jsxs("td",{className:"p-3",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-bold uppercase ${i.cls}`,children:[i.label==="OK"&&e.jsx(L,{className:"w-3 h-3"}),(i.label==="FAILED"||i.label==="DEGRADED")&&e.jsx(R,{className:"w-3 h-3"}),i.label]}),s.last_run_message&&s.last_run_status!=="succeeded"&&e.jsx("div",{className:"text-[10px] mt-1 max-w-[200px] truncate",title:s.last_run_message,children:s.last_run_message})]}),e.jsx("td",{className:"p-3 text-right font-mono",children:s.runs_24h}),e.jsx("td",{className:"p-3 text-right font-mono",children:e.jsx("span",{className:s.failures_24h>0?"font-bold underline":"",children:s.failures_24h})})]},s.jobid)})})]})}),e.jsxs("div",{className:"border-2 border-black p-4 text-xs space-y-1",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"OK"})," = last run succeeded, zero failures in 24h."]}),e.jsxs("div",{children:[e.jsx("strong",{children:"DEGRADED"})," = last run succeeded but at least one failure in the last 24h (system self-recovered)."]}),e.jsxs("div",{children:[e.jsx("strong",{children:"FAILED"})," = last cron firing returned an error. Check the message column."]}),e.jsxs("div",{children:[e.jsx("strong",{children:"NO RUNS"})," = job is scheduled but hasn't fired yet (newly created)."]}),e.jsxs("div",{className:"pt-2",children:["Auto-refreshes every 60s. Cron firings only â for the actual content publish outcome see ",e.jsx("a",{href:"/admin/pipeline",className:"underline",children:"/admin/pipeline"}),"."]})]})]})]}):e.jsxs("div",{className:"min-h-screen bg-white text-black flex items-center justify-center p-4",children:[e.jsxs(v,{children:[e.jsx("title",{children:"Schedule Status â Admin"}),e.jsx("meta",{name:"robots",content:"noindex,nofollow"})]}),e.jsxs("div",{className:"w-full max-w-md border-2 border-black p-8",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Admin Login"}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(k,{htmlFor:"email",children:"Email"}),e.jsx(w,{id:"email",type:"email",value:b,onChange:s=>S(s.target.value),required:!0,className:"rounded-none border-2 border-black"})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"password",children:"Password"}),e.jsx(w,{id:"password",type:"password",value:j,onChange:s=>A(s.target.value),required:!0,className:"rounded-none border-2 border-black"})]}),e.jsx(_,{type:"submit",disabled:f,className:"w-full rounded-none border-2 border-black",children:f?"
1Signing inâ¦":"Sign In"})]})]})]}):e.jsx("div",{className:"min-h-screen bg-white"})};function x({label:a,value:n,bold:r=!1}){return e.jsxs("div",{className:"border-2 border-black p-3",children:[e.jsx("div",{className:"text-[10px] uppercase",children:a}),e.jsx("div",{className:"text-2xl font-bold",children:n})]})}export{V 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.