fix: minor things before merging new order keys

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-02 19:03:34 +01:00
parent 7c387bb6ae
commit 25e3a84bf6
7 changed files with 42 additions and 48 deletions

View File

@@ -318,18 +318,13 @@ export function moveDataBetweenTables({
break;
}
// For monthly/weekly intervals with transform, we need to use the start of the next period for the upper bound
// For monthly/weekly intervals with transform, upperBoundDate should be currentDate
// because currentDate already represents the start of the period we're processing
// The WHERE clause uses > previousDate AND <= currentDate to get exactly one period
let upperBoundDate = currentDate;
if (interval === 'month' && batch.transform) {
const nextMonth = new Date(currentDate);
nextMonth.setMonth(nextMonth.getMonth() + 1);
nextMonth.setDate(1);
upperBoundDate = nextMonth;
} else if (interval === 'week' && batch.transform) {
const nextWeek = new Date(currentDate);
nextWeek.setDate(nextWeek.getDate() + 7);
const nextWeekStart = getWeekStart(nextWeek);
upperBoundDate = nextWeekStart;
// Don't exceed the endDate
if (upperBoundDate > endDate) {
upperBoundDate = endDate;
}
const sql = `INSERT INTO ${to}