![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/private_html/.next/server/pages/api/live-cases/ |
"use strict";(()=>{var e={};e.id=9661,e.ids=[9661],e.modules={8667:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return a}});var a=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},14748:(e,t,a)=>{a.r(t),a.d(t,{config:()=>c,default:()=>u,routeModule:()=>d});var r={};a.r(r),a.d(r,{default:()=>l});var n=a(33480),i=a(8667),s=a(86435);let o=new(a(96330)).PrismaClient;async function l(e,t){if("GET"!==e.method)return t.status(405).json({error:"Method not allowed"});try{let e=await o.legalCase.findMany({where:{isPublic:!0,status:{notIn:["COMPLETED","CANCELLED"]}},include:{creator:{select:{id:!0,name:!0,role:!0}},leadLawyer:{select:{id:!0,name:!0,role:!0}},_count:{select:{comments:!0,supporters:!0,offers:!0,registrations:!0}}}}),a=await o.user.findMany({where:{role:"LAWYER",isVerified:!0},select:{id:!0,name:!0,averageRating:!0,totalCases:!0,wonCases:!0}}),r=await o.user.findMany({where:{role:"CLIENT"},select:{id:!0}}),n=e.length,i=e.filter(e=>"ACTIVE"===e.status).length,s=e.filter(e=>"URGENT"===e.urgencyLevel).length,l=e.reduce((e,t)=>e+(t.estimatedValue||0),0),u=a.length,c=r.length,d=await o.legalCase.count({where:{status:"COMPLETED"}}),f=await o.legalCase.count({where:{status:{in:["COMPLETED","CANCELLED"]}}}),p=f>0?Math.round(d/f*100):0,g=(await o.legalCase.findMany({where:{isPublic:!0,offers:{some:{}}},include:{offers:{orderBy:{createdAt:"asc"},take:1}}})).map(e=>{if(e.offers.length>0){let t=e.offers[0];return new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()}return null}).filter(e=>null!==e),h=g.length>0?Math.round(g.reduce((e,t)=>e+t,0)/g.length/36e5):0,m=e.reduce((e,t)=>(t.category&&(e[t.category]=(e[t.category]||0)+1),e),{}),E=Object.entries(m).map(([e,t])=>({name:e,count:t,percentage:Math.round(t/n*100)})).sort((e,t)=>t.count-e.count).slice(0,10),A=e.reduce((e,t)=>(e[t.jurisdiction]=(e[t.jurisdiction]||0)+1,e),{}),P=Object.entries(A).map(([e,t])=>({name:e,count:t,percentage:Math.round(t/n*100)})).sort((e,t)=>t.count-e.count).slice(0,10),w=(await o.legalCase.findMany({where:{isPublic:!0},orderBy:{updatedAt:"desc"},take:10,include:{creator:{select:{name:!0}}}})).map(e=>{let t,a=Date.now()-new Date(e.updatedAt).getTime(),r=Math.floor(a/36e5),n=Math.floor(r/24);return t=n>0?`${n} day${n>1?"s":""} ago`:r>0?`${r} hour${r>1?"s":""} ago`:"Just now",{type:"CASE_UPDATE",description:`Case "${e.title}" was updated by ${e.creator.name}`,timestamp:t}}),y=[{type:"NEW_CASE",description:"New urgent case posted in Civil Litigation",timestamp:"2 hours ago"},{type:"LAWYER_JOIN",description:"5 new lawyers joined the platform",timestamp:"4 hours ago"},{type:"CASE_COMPLETED",description:"Family law case successfully resolved",timestamp:"1 day ago"},...w].slice(0,10);t.status(200).json({totalCases:n,activeCases:i,urgentCases:s,totalValue:l,averageCaseValue:Math.round(n>0?l/n:0),totalLawyers:u,totalClients:c,successRate:p,averageResponseTime:h,topCategories:E,topJurisdictions:P,recentActivity:y})}catch(e){console.error("Error fetching live cases stats:",e),t.status(500).json({error:"Failed to fetch statistics"})}finally{await o.$disconnect()}}let u=(0,s.M)(r,"default"),c=(0,s.M)(r,"config"),d=new n.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/live-cases/stats",pathname:"/api/live-cases/stats",bundlePath:"",filename:""},userland:r})},33480:(e,t,a)=>{e.exports=a(75600)},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},86435:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,a){return a in t?t[a]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,a)):"function"==typeof t&&"default"===a?t:void 0}}})},96330:e=>{e.exports=require("@prisma/client")}};var t=require("../../../webpack-api-runtime.js");t.C(e);var a=t(t.s=14748);module.exports=a})();