PageSourceSearch

https://www.pirate-portal.com/assets/HeatmapCommits-C-LT75r_.js

js pirate-portal.com collected 2026-10-04 18:17:38 UTC 7,585 bytes, 1 lines download raw bytes

1import{j as e}from"./react-pdf-CiRvGOjn.js";import{r as c}from"./ag-grid-react-Cvi7zz2g.js";import{O as T,f as a,_ as D,W as w,T as h,ar as B,a5 as M,Q as E}from"./index-BeCDJ2GY.js";import{T as k,a as W,b as A,c as C,d as P}from"./TableRow-0999PQhP.js";import{T as j}from"./TableCell-DxHRuWzH.js";import"./jspdf-D30lQ_ys.js";import"./ag-grid-community-DgkugROF.js";import"./ag-grid-enterprise-BRKZrOzu.js";import"./ag-charts-B9701BJR.js";import"./microsoft-BQSsBj1o.js";const F={Monday:"Mon",Tuesday:"Tue",Wednesday:"Wed",Thursday:"Thu",Friday:"Fri",Saturday:"Sat",Sunday:"Sun"},R={Mon:0,Tue:0,Wed:0,Thu:0,Fri:0,Sat:0,Sun:0},L=t=>t?.name==="CanceledError"||T.isCancel?.(t);function S(t){return{id:t?.id??t?.Id??null,name:t?.name??t?.Name??"",email:t?.email??t?.Email??"",lastModifiedDay:t?.lastModifiedDay??t?.LastModifiedDay??"",commits:Number(t?.commits??t?.Commits??0)}}function N(t){if(!Array.isArray(t))return{};const i={};return t.map(S).forEach(({name:n,lastModifiedDay:u,commits:m})=>{if(!n)return;i[n]||(i[n]={...R});const l=F[u];l&&(i[n][l]=Number.isFinite(m)?m:0)}),i}function H(){const[t,i]=c.useState([]),[n,u]=c.useState({}),[m,l]=c.useState(!0),[f,x]=c.useState(null),o=c.useCallback(async d=>{l(!0),x(null);try{const r=await T.get("/api/Audit/project-commits",{signal:d}),g=Array.isArray(r?.data)?r.data:[],p=g.map(S),y=N(g);return d?.aborted||(i(p),u(y)),{rawData:p,commitData:y}}catch(r){return L(r)||d?.aborted?{rawData:[],commitData:{}}:(i([]),u({}),x(r?.response?.data?.message||r?.message||"Failed to load project commits"),{rawData:[],commitData:{}})}finally{d?.aborted||l(!1)}},[]);c.useEffect(()=>{const d=new AbortController;return o(d.signal),()=>{d.abort()}},[o]);const s=c.useMemo(()=>Object.keys(n).sort((d,r)=>d.localeCompare(r)),[n]);return{commitData:n,orderedNames:s,rawData:t,loading:m,error:f,refetch:o}}const U=t=>t?.name==="CanceledError"||T.isCancel?.(t);function z(t){return{metric:t?.metric??t?.Metric??"",key:t?.key??t?.Key??"",value:Number(t?.value??t?.Value??0)}}const b={Totals:[],ByUser:[],ByDay:[],ByType:[],ByColumn:[],ByProject:[]};function I(){const[t,i]=c.useState([]),[n,u]=c.useState(!0),[m,l]=c.useState(null),f=c.useCallback(async o=>{u(!0),l(null);try{const s=await T.get("/api/Audit/project-commit-metrics",{signal:o}),r=(Array.isArray(s?.data)?s.data:[]).map(z);return o?.aborted||i(r),r}catch(s){return U(s)||o?.aborted?[]:(i([]),l(s?.response?.data?.message||s?.message||"Failed to load project commit metrics"),[])}finally{o?.aborted||u(!1)}},[]);c.useEffect(()=>{const o=new AbortController;return f(o.signal),()=>{o.abort()}},[f]);const x=c.useMemo(()=>{const o={Totals:[],ByUser:[],ByDay:[],ByType:[],ByColumn:[],ByProject:[]};return t.forEach(s=>{o[s.metric]&&o[s.metric].push({key:s.key,value:s.value})}),o},[t]);return{loading:n,error:m,totals:x.Totals??b.Totals,byUser:x.ByUser??b.ByUser,byDay:x.ByDay??b.ByDay,byType:x.ByType??b.ByType,byColumn:x.ByColumn??b.ByColumn,byProject:x.ByProject??b.ByProject,raw:t,refetch:f}}const v=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],$=t=>t>50?"#1EEDC2":t>25?"#16C4A0":t>15?"#109C7F":t>5?"#065B4A":t>0?"#2C2C2C":"#ffffff",K=t=>e.jsx(h,{variant:"subtitle2",sx:{fontWeight:700,opacity:.9,mb:1},children:t});function Y({label:t,value:i,max:n,color:u="#16C4A0",labelWidth:m=160}){const l=n>0?Math.round(i/n*100):0;return e.jsxs(a,{sx:{display:"grid",gridTemplateColumns:`${m}px 1fr 48px`,gap:1,alignItems:"center",mb:.75},children:[e.jsx(h,{variant:"body2",noWrap:!0,sx:{opacity:.9},title:t,children:t}),e.jsx(a,{sx:{height:14,bgcolor:"action.hover",borderRadius:7,overflow:"hidden"},children:e.jsx(a,{sx:{width:`${l}%`,height:"100%",bgcolor:u}})}),e.jsx(h,{variant:"caption",sx:{textAlign:"right",opacity:.85},children:i})]})}const te=()=>{const{commitData:t,orderedNames:i,loading:n,error:u}=H(),{loading:m,error:l,totals:f,byUser:x}=I(),o=c.useMemo(()=>f.find(r=>(r.key||"").toLowerCase()==="totalchanges")?.value??0,[f]),s=c.useMemo(()=>{const r=[...x].filter(p=>p?.key).sort((p,y)=>(y?.value||0)-(p?.value||0)).slice(0,10),g=Math.max(0,...r.map(p=>p?.value||0));return{rows:r,max:g}},[x]),d=340;return e.jsx(a,{sx:{width:"100%"},children:e.jsxs(D,{direction:{xs:"column",md:"row"},spacing:1.5,sx:{alignItems:"stretch"},children:[e.jsx(a,{sx:{flex:{xs:"1 1 auto",md:"0 0 66.666%"},minWidth:0},children:e.jsxs(w,{sx:{height:d,p:2.25,borderRadius:2,boxShadow:2,display:"flex",flexDirection:"column",gap:1.5},children:[e.jsxs(a,{sx:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:1},children:[e.jsx(h,{variant:"h6",sx:{fontWeight:800},children:"This Week’s Activity"}),e.jsx(h,{variant:"body2",sx:{opacity:.75},children:m?"Loading…":`Total changes: ${o}`})]}),m?e.jsx(a,{sx:{px:1,pt:1},children:e.jsx(B,{})}):l?e.jsxs(h,{color:"error",variant:"body2",children:["Metrics error: ",String(l)]}):e.jsxs(e.Fragment,{children:[e.jsxs(a,{sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[K("Commits by PM (Top 10)"),e.jsx(a,{sx:{flex:1,overflowY:"auto",pr:.5},children:s.rows.length===0?e.jsx(h,{variant:"caption",sx:{opacity:.7},children:"No PM activity this week"}):s.rows.map(r=>e.jsx(Y,{label:r.key,value:r.value,max:s.max},r.key))})]}),e.jsx(M,{}),e.jsx(h,{variant:"caption",sx:{opacity:.65},children:"Tip: hover the heatmap cells to see each PM’s per-day counts for the current week."})]})]})}),e.jsx(a,{sx:{flex:{xs:"1 1 auto",md:"0 0 33.333%"},minWidth:0},children:e.jsxs(w,{sx:{height:d,p:1.25,borderRadius:2,boxShadow:2,display:"flex",flexDirection:"column"},children:[e.jsx(h,{variant:"subtitle1",sx:{fontWeight:800,px:1,pb:1},children:"Weekly Project Commit Heatmap"}),e.jsx(k,{sx:{flex:1,overflow:"auto",borderRadius:1,border:"1px solid",borderColor:"divider"},children:e.jsxs(W,{stickyHeader:!0,size:"small","aria-label":"Weekly project commit heatmap",children:[e.jsx(A,{children:e.jsxs(C,{children:[e.jsx(j,{sx:{backgroundColor:"#222",color:"#fff",fontWeight:"bold",minWidth:128,p:.5},children:"Name"}),v.map(r=>e.jsx(j,{sx:{backgroundColor:"#222",color:"#fff",fontWeight:"bold",width:30,p:.5,textAlign:"center"},children:r},r))]})}),e.jsx(P,{children:n?e.jsx(C,{children:e.jsx(j,{colSpan:8,children:"Loading…"})}):u?e.jsx(C,{children:e.jsxs(j,{colSpan:8,sx:{color:"error.main"},children:["Error: ",String(u)]})}):!t||i.length===0?e.jsx(C,{children:e.jsx(j,{colSpan:8,children:"No data"})}):i.map(r=>{const g=t[r]||{};return e.jsxs(C,{hover:!0,children:[e.jsx(j,{sx:{fontSize:12,p:.5},title:r,children:e.jsx(h,{variant:"caption",noWrap:!0,children:r})}),v.map(p=>{const y=g?.[p]||0;return e.jsx(j,{sx:{width:30,height:22,p:.5,textAlign:"center",backgroundColor:$(y),border:"1px solid rgba(0,0,0,.06)"},children:e.jsx(E,{title:`${y} commits`,arrow:!0,disableInteractive:!0,children:e.jsx(a,{sx:{width:"100%",height:"100%",minHeight:14}})})},p)})]},r)})})]})}),e.jsxs(a,{sx:{display:"flex",gap:1,justifyContent:"flex-start",alignItems:"center",mt:1,px:.5,flexWrap:"nowrap",overflowX:"auto"},children:[e.jsx(a,{sx:{bgcolor:"#ffffff",px:1,py:.25,border:"1px solid #ddd",whiteSpace:"nowrap"},children:"0"}),e.jsx(a,{sx:{bgcolor:"#2C2C2C",px:1,py:.25,color:"#fff",whiteSpace:"nowrap"},children:"1-5"}),e.jsx(a,{sx:{bgcolor:"#065B4A",px:1,py:.25,color:"#fff",whiteSpace:"nowrap"},children:"6-15"}),e.jsx(a,{sx:{bgcolor:"#109C7F",px:1,py:.25,color:"#fff",whiteSpace:"nowrap"},children:"16-25"}),e.jsx(a,{sx:{bgcolor:"#16C4A0",px:1,py:.25,color:"#fff",whiteSpace:"nowrap"},children:"26-50"}),e.jsx(a,{sx:{bgcolor:"#1EEDC2",px:1,py:.25,fontWeight:700,whiteSpace:"nowrap"},children:"50+"})]})]})})]})})};export{te 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.