Add dashboard report snapshots feature with CRUD operations. Implemented new database migrations for dashboard_report_snapshots, including report type handling. Updated backend routes and models to support snapshot retrieval and upsert functionality. Enhanced frontend components to integrate report snapshot management, including UI for daily and end-cycle reports. Added tests for new functionality to ensure reliability.
CI / lint-and-test (push) Canceled after 0s

This commit is contained in:
Alberto-Audrix committed 2026-08-13 15:46:16 +07:00
1 parent 059087be1d
commit 34336b9bd1
41 files changed
+4824 -178

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
/** Accuracy % or N/A (null) for IoT vs manual report cells. */
export type ReportAccuracy = number | null;
export interface DashboardReportCountingRow {
date: string;
day: number;
countBefore: number | null;
mortality: number | null;
harvest: number | null;
harvestWeight: number | null;
countAfter: number | null;
iotCount: number | null;
accuracy: ReportAccuracy;
}
export interface DashboardReportWeightRow {
date: string;
day: number;
avgManual: number | null;
avgIot: number | null;
uniformity: number | null;
difference: number | null;
accuracy: ReportAccuracy;
}
export interface DashboardReportFeedInRow {
date: string;
manualIn: number | null;
iotIn: number | null;
accuracy: ReportAccuracy;
}
export interface DashboardReportFeedUseRow {
date: string;
day: number;
manualUse: number | null;
iotUse: number | null;
accuracy: ReportAccuracy;
}
export type DashboardReportType = 'daily' | 'end_cycle';
export interface DashboardReportFcrRow {
day: number;
iotFcr: number | null;
feedTotal: number | null;
iotWeight: number | null;
chickenLife: number | null;
harvestWeightTotal: number | null;
}
export interface DashboardReportEefRow {
day: number;
iotEef: number | null;
chickenLifePercentage: number | null;
iotAverageHarvestBw: number | null;
iotAverageDayWeight: number | null;
iotFcr: number | null;
}
export interface DashboardReportPayload {
cycleId: string;
kandangId: number;
kandangName: string;
area: string;
upToDay: number;
generatedAt: string;
reportType?: DashboardReportType;
counting: DashboardReportCountingRow[];
weight: DashboardReportWeightRow[];
feedIn: DashboardReportFeedInRow[];
feedUse: DashboardReportFeedUseRow[];
fcr?: DashboardReportFcrRow[];
eef?: DashboardReportEefRow[];
}
export interface DashboardReportSnapshotRecord {
id: number;
cycleId: string;
kandangId: number;
upToDay: number;
generatedAt: string;
reportType?: DashboardReportType;
payload: DashboardReportPayload;
createdAt?: string;
updatedAt?: string;
}
export interface DashboardReportSnapshotResponse {
success: boolean;
data: DashboardReportSnapshotRecord | null;
message?: string;
error?: string;
}