Remove all ControlPlaneClient infrastructure, WorkOS auth, managed proxy, platform profile loading, org policy enforcement, and credits UI. Config is now fully local — only file-based config.yaml and .env secrets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { BaseSessionMetadata } from "core";
|
|
|
|
export const parseDate = (date: string): Date => {
|
|
let dateObj = new Date(date);
|
|
if (isNaN(dateObj.getTime())) {
|
|
dateObj = new Date(parseInt(date));
|
|
}
|
|
return dateObj;
|
|
};
|
|
|
|
export interface SessionGroup {
|
|
label: string;
|
|
sessions: BaseSessionMetadata[];
|
|
}
|
|
|
|
export const groupSessionsByDate = (
|
|
sessions: BaseSessionMetadata[],
|
|
): SessionGroup[] => {
|
|
const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 24);
|
|
const lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7);
|
|
const lastMonth = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30);
|
|
|
|
const groups: SessionGroup[] = [];
|
|
|
|
const todaySessions = sessions.filter(
|
|
(session) => parseDate(session.dateCreated) > yesterday,
|
|
);
|
|
const weekSessions = sessions.filter((session) => {
|
|
const date = parseDate(session.dateCreated);
|
|
return date <= yesterday && date > lastWeek;
|
|
});
|
|
const monthSessions = sessions.filter((session) => {
|
|
const date = parseDate(session.dateCreated);
|
|
return date <= lastWeek && date > lastMonth;
|
|
});
|
|
const olderSessions = sessions.filter(
|
|
(session) => parseDate(session.dateCreated) <= lastMonth,
|
|
);
|
|
|
|
if (todaySessions.length > 0)
|
|
groups.push({ label: "Today", sessions: todaySessions });
|
|
if (weekSessions.length > 0)
|
|
groups.push({ label: "This Week", sessions: weekSessions });
|
|
if (monthSessions.length > 0)
|
|
groups.push({ label: "This Month", sessions: monthSessions });
|
|
if (olderSessions.length > 0)
|
|
groups.push({ label: "Older", sessions: olderSessions });
|
|
|
|
return groups;
|
|
};
|