decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 1.79 kB
JavaScript
import{i as c,b as u}from"./config-LEYSFIMn.js";const l=new Set(["post_deploy_validation","done"]),h=new Set(["done","archived"]);function d(t){if(!l.has(t.status)||!t.updatedAt)return null;const e=Date.parse(t.updatedAt);return Number.isNaN(e)?null:e}function m(t,e){return t.filter(n=>(d(n)??-1/0)>=e).length}function D(t,e){return t.filter(n=>h.has(n.status)?!1:e&&n.assigneeId===e?!0:c(n)||u(n)).sort((n,r)=>(n.updatedAt??"").localeCompare(r.updatedAt??""))}function w(t){return c(t)?"answer":u(t)?"review":"assigned"}function M(t){const e=[];for(const n of t)for(const r of n.threads)r.status==="in_progress"&&e.push({threadId:r.threadId,taskId:n.id,taskTitle:n.title,runTitle:r.title,startedAt:r.createdAt});return e.sort((n,r)=>r.startedAt.localeCompare(n.startedAt))}const N=14;function g(t,e,n=Date.now()){const r=new Array(e).fill(0);for(const a of t){const i=d(a);if(i===null)continue;const s=e-1-Math.floor(Math.max(0,n-i)/864e5);s>=0&&s<e&&(r[s]+=1)}return r}function S(t,e,n=Date.now()){const r=new Array(e).fill(0);for(const a of t)for(const i of a.threads){const s=Date.parse(i.lastActiveAt);if(Number.isNaN(s))continue;const o=e-1-Math.floor(Math.max(0,n-s)/864e5);o>=0&&o<e&&(r[o]+=1)}return r}function p(t){const e=new Date(t);e.setDate(1),e.setHours(0,0,0,0);const n=e.getTime();return{since:n,days:Math.floor((t-n)/864e5)+1}}function T(t,e=Date.now()){const{since:n,days:r}=p(e),a=new Array(r).fill(0);for(const i of t)for(const s of i.threads){const o=Date.parse(s.lastActiveAt);if(Number.isNaN(o)||o<n||o>e)continue;const f=Math.floor((o-n)/864e5);f>=0&&f<r&&(a[f]+=s.costUsd??0)}return a}function x(t){return t<=0?"$0":t>=1e3?`$${(t/1e3).toFixed(1)}k`:t>=10?`$${Math.round(t)}`:`$${t.toFixed(2)}`}export{N as R,w as a,g as b,S as c,T as d,x as f,M as r,m as s,D as t};