PageSourceSearch

https://ryplaced.ai/assets/ContentAnalytics-VqwQrGxE.js

js ryplaced.ai collected 2026-10-05 14:32:39 UTC 7,405 bytes, 1 lines download raw bytes

1import{r as u,j as e}from"./motion-CosRO9bq.js";import{a as A,F as C,L as S,br as j,j as o,a7 as g,Y as T}from"./App-B9yavX8s.js";import"./i18n-DM4FnftC.js";import{S as D,a as E,b as I,c as R,d as r}from"./select-eGq0lKF4.js";import{s as F}from"./client-ON1bHuT4.js";import{P as y}from"./play-BML5bVx6.js";import{C as N}from"./circle-check-Ct3dWS-5.js";import{S as L}from"./star-D62TV5RZ.js";import"./index-BmHsUbC1.js";import"./charts-mzLkVtyt.js";import"./index-0ZK6rZ-N.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"a43e79a71eadc3928e287951d574ba9a9663ba9f"}}catch{}})();try{(function(){var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new s.Error().stack;l&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[l]="77fb3aea-f129-460d-93e3-628fec98cfbf",s._sentryDebugIdIdentifier="sentry-dbid-77fb3aea-f129-460d-93e3-628fec98cfbf")})()}catch{}function U(){const{t:s}=A(["admin-content","common"]),[l,b]=u.useState("30"),[n,d]=u.useState(void 0),m=new Date().toISOString().split("T")[0],{data:c,isLoading:v,error:p}=C({queryKey:["content-analytics-dashboard",l,n],queryFn:async()=>{const t={_range:l};l==="custom"&&(n!=null&&n.from)&&(n!=null&&n.to)&&(t._custom_from=`${n.from}T00:00:00Z`,t._custom_to=`${n.to}T23:59:59.999Z`);const{data:a,error:f}=await F.rpc("get_content_analytics_summary",t);if(f)throw console.error("[ContentAnalytics] RPC error:",f),f;return(a||[]).map(i=>({content_type:i.ctype,content_id:i.cid,title:i.ctitle,views:Number(i.view_count)||0,starts:Number(i.start_count)||0,completions:Number(i.complete_count)||0,avg_rating:Number(i.avg_rating)||0,rating_count:Number(i.rating_count)||0}))},refetchInterval:3e4}),w=(c==null?void 0:c.reduce((t,a)=>t+a.views,0))||0,x=(c==null?void 0:c.reduce((t,a)=>t+a.starts,0))||0,h=(c==null?void 0:c.reduce((t,a)=>t+a.completions,0))||0,_=x>0?(h/x*100).toFixed(1):"0";return v?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(S,{variant:"dot",size:"lg",className:"text-primary"})}):p?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("p",{className:"text-destructive",children:["Error loading analytics: ",p.message]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading font-bold",children:s("admin-content:contentAnalytics.title")}),e.jsx("p",{className:"text-muted-foreground",children:s("admin-content:contentAnalytics.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(D,{value:l,onValueChange:t=>{b(t),t!=="custom"&&d(void 0)},children:[e.jsx(E,{className:"w-[140px]",children:e.jsx(I,{})}),e.jsxs(R,{children:[e.jsx(r,{value:"7",children:s("admin-content:contentAnalytics.dateRange.last7Days")}),e.jsx(r,{value:"30",children:s("admin-content:contentAnalytics.dateRange.last30Days")}),e.jsx(r,{value:"90",children:s("admin-content:contentAnalytics.dateRange.last90Days")}),e.jsx(r,{value:"365",children:s("admin-content:contentAnalytics.dateRange.lastYear")}),e.jsx(r,{value:"all",children:s("admin-content:contentAnalytics.dateRange.allTime")}),e.jsx(r,{value:"custom",children:s("admin-content:contentAnalytics.dateRange.customRange")})]})]}),l==="custom"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j,{type:"date","aria-label":"Custom range start",className:"w-[150px] h-9 text-sm",value:(n==null?void 0:n.from)??"",max:(n==null?void 0:n.to)||m,onChange:t=>d(a=>({from:t.target.value,to:(a==null?void 0:a.to)??m}))}),e.jsx("span",{className:"text-muted-foreground text-sm",children:s("admin-content:contentAnalytics.dateRange.to")}),e.jsx(j,{type:"date","aria-label":"Custom range end",className:"w-[150px] h-9 text-sm",value:(n==null?void 0:n.to)??"",min:(n==null?void 0:n.from)??"",max:m,onChange:t=>d(a=>({from:(a==null?void 0:a.from)??"",to:t.target.value}))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-8 h-8 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin-content:contentAnalytics.totalViews")}),e.jsx("p",{className:"text-2xl font-bold",children:w})]})]})}),e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y,{className:"w-8 h-8 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin-content:contentAnalytics.totalStarts")}),e.jsx("p",{className:"text-2xl font-bold",children:x})]})]})}),e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(N,{className:"w-8 h-8 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin-content:contentAnalytics.totalCompletions")}),e.jsx("p",{className:"text-2xl font-bold",children:h})]})]})}),e.jsx(o,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{className:"w-8 h-8 text-accent"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin-content:contentAnalytics.completionRate")}),e.jsxs("p",{className:"text-2xl font-bold",children:[_,"%"]})]})]})})]}),e.jsxs(o,{className:"p-6",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:s("admin-content:contentAnalytics.contentPerformance")}),e.jsxs("div",{className:"space-y-4",children:[c==null?void 0:c.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-1 bg-muted rounded capitalize",children:t.content_type.replace("_"," ")}),e.jsx("h3",{className:"font-semibold",children:t.title})]}),e.jsxs("div",{className:"flex gap-6 mt-2 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(g,{className:"w-4 h-4"})," ",t.views," ",s("admin-content:contentAnalytics.views")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(y,{className:"w-4 h-4"})," ",t.starts," ",s("admin-content:contentAnalytics.starts")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-4 h-4"})," ",t.completions," ",s("admin-content:contentAnalytics.completions")]}),t.rating_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"w-4 h-4 fill-yellow-500 text-yellow-500"}),t.avg_rating.toFixed(1)," (",t.rating_count,")"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-2xl font-bold",children:[t.starts>0?(t.completions/t.starts*100).toFixed(0):"0","%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("admin-content:contentAnalytics.completion")})]})]},`${t.content_type}-${t.content_id}`)),(!c||c.length===0)&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:s("admin-content:contentAnalytics.noData")})]})]})]})}export{U 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.