Introduce a Woodpecker CI/CD pipeline in `.woodpecker.yml` for automated deployment on pushes to the main branch. Add new components for visualizing campaign performance, including `DailyPerformanceChart`, `InboxPlacementChart`, and `InboxVsSpamChart`, to enhance the Campaign Detail page. Update `WarmupPlanChart` to include additional metrics and improve tooltip information. Enhance utility functions for chart data formatting and daily statistics mapping.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { CampaignStatsToday } from '@warmbox/shared';
|
|
|
|
export function formatChartDate(iso: string): string {
|
|
const d = new Date(`${iso}T12:00:00`);
|
|
return d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
|
|
}
|
|
|
|
export function last7DaysIsoRange(): { from: string; to: string } {
|
|
const to = new Date();
|
|
const from = new Date();
|
|
from.setDate(from.getDate() - 6);
|
|
const toIso = to.toISOString().slice(0, 10);
|
|
const fromIso = from.toISOString().slice(0, 10);
|
|
return { from: fromIso, to: toIso };
|
|
}
|
|
|
|
export type DailyChartRow = {
|
|
dayIndex: number;
|
|
label: string;
|
|
date: string;
|
|
plannedSends: number;
|
|
plannedReplies: number;
|
|
sends: number;
|
|
replies: number;
|
|
spam: number;
|
|
inbox: number;
|
|
};
|
|
|
|
export function mapDailyStatToChartRow(stat: CampaignStatsToday): DailyChartRow {
|
|
return {
|
|
dayIndex: stat.dayIndex,
|
|
label: formatChartDate(stat.date),
|
|
date: stat.date,
|
|
plannedSends: stat.planned.sends,
|
|
plannedReplies: stat.planned.replies,
|
|
sends: stat.actual.sends,
|
|
replies: stat.actual.replies,
|
|
spam: stat.actual.spamDetected,
|
|
inbox: Math.max(0, stat.actual.sends - stat.actual.spamDetected),
|
|
};
|
|
}
|