PageSourceSearch

https://constructionchampionspodcast.com/assets/ContentExtraction-BLyfK6XX.js

js constructionchampionspodcast.com collected 2026-10-02 15:20:20 UTC 6,503 bytes, 1 lines download raw bytes

1import{D as L,q as T,V as K,r as w,u as v,j as e,w as C,B as k,b as q,h as F,s as a}from"./index-Bir8wyl1.js";import{A as I}from"./AdminLayout-DbBZvZQe.js";import{C as r,a as l,b as d,c as n}from"./card-DxXvY32Y.js";import{B as _}from"./badge-pWj4rKxt.js";import{P as z}from"./progress-DMORmCN9.js";import{C as R}from"./circle-help-vDPYjCO3.js";import{L as H}from"./lightbulb-B3lc5Izr.js";import{T as $}from"./tag-CuFTMz-O.js";import{S as E}from"./sparkles-CzTeYqCy.js";import{F as D}from"./file-text-Dz4mKxYn.js";import"./sheet-DTkl0rqb.js";import"./index-Bkw_-bVb.js";import"./Combination-BROvjVdl.js";import"./separator-eo0ILj3i.js";import"./panel-left-DDJGVpsS.js";import"./index-DiS3G9jk.js";import"./search-check-DSxqUVvt.js";import"./shield-t2qEge2d.js";import"./settings-vcBfnKFV.js";import"./house-DtYcwxiH.js";import"./log-out-S_vSYtaP.js";import"./chevron-right-CwZRG0g_.js";import"./mic-CO4jsAvB.js";import"./zap-C55pg-W6.js";import"./radio-WaQX2rrP.js";import"./shield-check-DBkwcs7j.js";import"./search-CP3BKgym.js";import"./dollar-sign-BYAluLJk.js";import"./chart-column-Cs5T04A-.js";import"./mail-DamUgfhE.js";import"./message-square-OwSzLUMg.js";import"./file-pen-line-dZuno8e-.js";const we=()=>{const{user:m,isAdmin:x,isLoading:B}=L(),{toast:o}=T(),c=K(),[u,g]=w.useState(!1),[j,y]=w.useState(null),{data:h,isLoading:P}=v({queryKey:["admin-posts-extraction"],queryFn:async()=>{const{data:s,error:t}=await a.from("blog_posts").select("id, title, slug, status, ai_extracted").eq("status","published").order("published_at",{ascending:!1});if(t)throw t;return s||[]},enabled:!!m&&x}),{data:p}=v({queryKey:["extraction-stats"],queryFn:async()=>{const[s,t,i]=await Promise.all([a.from("blog_post_questions").select("id",{count:"exact",head:!0}),a.from("blog_post_insights").select("id",{count:"exact",head:!0}),a.from("blog_post_topics").select("id",{count:"exact",head:!0})]);return{questions:s.count||0,insights:t.count||0,topics:i.count||0}},enabled:!!m&&x}),b=h?.filter(s=>s.ai_extracted).length||0,f=h?.length||0,A=f>0?b/f*100:0,Q=async s=>{y(s);try{const{data:{session:t}}=await a.auth.getSession(),{data:i,error:N}=await a.functions.invoke("extract-blog-content",{body:{post_id:s},headers:{Authorization:`Bearer ${t?.access_token}`}});if(N)throw N;o({title:"Content extracted",description:i.message}),c.invalidateQueries({queryKey:["admin-posts-extraction"]}),c.invalidateQueries({queryKey:["extraction-stats"]})}catch(t){o({title:"Extraction failed",description:t.message,variant:"destructive"})}finally{y(null)}},S=async()=>{g(!0);try{const{data:{session:s}}=await a.auth.getSession(),{data:t,error:i}=await a.functions.invoke("extract-blog-content",{body:{bulk:!0},headers:{Authorization:`Bearer ${s?.access_token}`}});if(i)throw i;o({title:"Bulk extraction complete",description:t.message}),c.invalidateQueries({queryKey:["admin-posts-extraction"]}),c.invalidateQueries({queryKey:["extraction-stats"]})}catch(s){o({title:"Bulk extraction failed",description:s.message,variant:"destructive"})}finally{g(!1)}};return B?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"})}):!m||!x?null:e.jsx(I,{title:"AI Content Extraction",description:"Extract Q&A, insights, and topic tags from blog posts using AI",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(r,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Extracted Posts"}),e.jsx(C,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(n,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[b," / ",f]}),e.jsx(z,{value:A,className:"mt-2"})]})]}),e.jsxs(r,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Questions Generated"}),e.jsx(R,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(n,{children:e.jsx("div",{className:"text-2xl font-bold",children:p?.questions||0})})]}),e.jsxs(r,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Insights Extracted"}),e.jsx(H,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(n,{children:e.jsx("div",{className:"text-2xl font-bold",children:p?.insights||0})})]}),e.jsxs(r,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Topic Tags"}),e.jsx($,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(n,{children:e.jsx("div",{className:"text-2xl font-bold",children:p?.topics||0})})]})]}),e.jsx(r,{children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-semibold text-lg",children:"Bulk Extract Content"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Process up to 10 unextracted posts at a time. Run multiple times to process all posts."})]}),e.jsxs(k,{onClick:S,disabled:u,className:"gap-2",children:[u?e.jsx(q,{className:"w-4 h-4 animate-spin"}):e.jsx(E,{className:"w-4 h-4"}),u?"Processing...":"Extract Next Batch"]})]})})}),P?e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsx(F,{className:"h-16 w-full"},s))}):e.jsx("div",{className:"space-y-2",children:h?.map(s=>e.jsx(r,{className:"hover:border-primary/30 transition-colors",children:e.jsx(n,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(D,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:s.title}),s.ai_extracted?e.jsxs(_,{className:"bg-green-500/20 text-green-400 border-green-500/50 flex-shrink-0",children:[e.jsx(C,{className:"w-3 h-3 mr-1"})," Extracted"]}):e.jsx(_,{variant:"secondary",className:"flex-shrink-0",children:"Pending"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>Q(s.id),disabled:j===s.id,className:"gap-1 flex-shrink-0",children:[j===s.id?e.jsx(q,{className:"w-3 h-3 animate-spin"}):e.jsx(E,{className:"w-3 h-3"}),s.ai_extracted?"Re-extract":"Extract"]})]})})},s.id))})]})})};export{we 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.