refactor: modularize application domains
This commit is contained in:
@@ -292,11 +292,14 @@ export async function getOrGenerateDailyMileageReport(reportDate: string): Promi
|
||||
return generateDailyMileageReport(reportDate, 'PREVIEW', 'LIVE');
|
||||
}
|
||||
|
||||
export async function archiveDailyMileageReport(reportDate: string): Promise<DailyMileageReport> {
|
||||
export async function archiveDailyMileageReport(
|
||||
reportDate: string,
|
||||
options: { replace?: boolean } = {},
|
||||
): Promise<DailyMileageReport> {
|
||||
const existing = await getDailyReportSnapshot(reportDate);
|
||||
if (existing) return existing;
|
||||
if (existing && !options.replace) return existing;
|
||||
const report = await generateDailyMileageReport(reportDate, 'ARCHIVED', 'AUTO');
|
||||
await saveDailyReportSnapshot(report, 'AUTO');
|
||||
await saveDailyReportSnapshot(report, 'AUTO', { replace: options.replace });
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user