mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Fix timezone-dependent test failures in Insights weekly compaction (#15680)
This commit is contained in:
@@ -436,7 +436,7 @@ describe('compaction', () => {
|
||||
// 2000-01-03 is a Monday
|
||||
DateTime.utc(2000, 1, 3, 0, 0),
|
||||
DateTime.utc(2000, 1, 5, 23, 59),
|
||||
DateTime.utc(2000, 1, 11, 1, 0),
|
||||
DateTime.utc(2000, 1, 10, 1, 0),
|
||||
],
|
||||
batches: [2, 1],
|
||||
},
|
||||
@@ -446,9 +446,9 @@ describe('compaction', () => {
|
||||
// 2000-01-03 is a Monday
|
||||
DateTime.utc(2000, 1, 3, 0, 0),
|
||||
DateTime.utc(2000, 1, 4, 23, 59),
|
||||
DateTime.utc(2000, 1, 11, 0, 0),
|
||||
DateTime.utc(2000, 1, 12, 23, 59),
|
||||
DateTime.utc(2000, 1, 18, 23, 59),
|
||||
DateTime.utc(2000, 1, 10, 0, 0),
|
||||
DateTime.utc(2000, 1, 11, 23, 59),
|
||||
DateTime.utc(2000, 1, 17, 23, 59),
|
||||
],
|
||||
batches: [2, 2, 1],
|
||||
},
|
||||
@@ -482,7 +482,7 @@ describe('compaction', () => {
|
||||
const allCompacted = await insightsByPeriodRepository.find({ order: { periodStart: 1 } });
|
||||
expect(allCompacted).toHaveLength(batches.length);
|
||||
for (const [index, compacted] of allCompacted.entries()) {
|
||||
expect(compacted.periodStart.getDay()).toBe(1);
|
||||
expect(compacted.periodStart.getUTCDay()).toBe(1);
|
||||
expect(compacted.value).toBe(batches[index]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ export class InsightsByPeriodRepository extends Repository<InsightsByPeriod> {
|
||||
// SQLite by default
|
||||
let periodStartExpr =
|
||||
periodUnitToCompactInto === 'week'
|
||||
? "strftime('%Y-%m-%d 00:00:00.000', date(periodStart, 'weekday 0', '-6 days'))"
|
||||
? "strftime('%Y-%m-%d 00:00:00.000', date(periodStart, '-6 days', 'weekday 1'))"
|
||||
: `strftime('%Y-%m-%d ${periodUnitToCompactInto === 'hour' ? '%H' : '00'}:00:00.000', periodStart)`;
|
||||
if (dbType === 'mysqldb' || dbType === 'mariadb') {
|
||||
periodStartExpr =
|
||||
|
||||
Reference in New Issue
Block a user