Skip to content

Commit 893a96b

Browse files
ireneeaByteEVM
authored andcommitted
fix: Fix insights query date range calculation in backend (n8n-io#21409)
1 parent 2e431af commit 893a96b

File tree

6 files changed

+1224
-634
lines changed

6 files changed

+1224
-634
lines changed

packages/cli/src/modules/insights/__tests__/insights.controller.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ afterAll(async () => {
2828
describe('InsightsController', () => {
2929
const insightsByPeriodRepository = mockInstance(InsightsByPeriodRepository);
3030
let controller: InsightsController;
31-
const sevenDaysAgo = DateTime.now().minus({ days: 7 }).toJSDate();
31+
const sixDaysAgo = DateTime.now().minus({ days: 6 }).toJSDate();
3232
const today = DateTime.now().toJSDate();
3333
const licenseState = mock<LicenseState>();
3434

@@ -62,7 +62,7 @@ describe('InsightsController', () => {
6262

6363
const callArgs =
6464
insightsByPeriodRepository.getPreviousAndCurrentPeriodTypeAggregates.mock.calls[0][0];
65-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
65+
expectDatesClose(callArgs.startDate, sixDaysAgo);
6666
expectDatesClose(callArgs.endDate, today);
6767

6868
expect(response).toEqual({
@@ -102,7 +102,7 @@ describe('InsightsController', () => {
102102

103103
const callArgs =
104104
insightsByPeriodRepository.getPreviousAndCurrentPeriodTypeAggregates.mock.calls[0][0];
105-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
105+
expectDatesClose(callArgs.startDate, sixDaysAgo);
106106
expectDatesClose(callArgs.endDate, today);
107107

108108
expect(response).toEqual({
@@ -146,7 +146,7 @@ describe('InsightsController', () => {
146146

147147
const callArgs =
148148
insightsByPeriodRepository.getPreviousAndCurrentPeriodTypeAggregates.mock.calls[0][0];
149-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
149+
expectDatesClose(callArgs.startDate, sixDaysAgo);
150150
expectDatesClose(callArgs.endDate, today);
151151

152152
expect(response).toEqual({
@@ -399,7 +399,7 @@ describe('InsightsController', () => {
399399
});
400400

401401
const callArgs = insightsByPeriodRepository.getInsightsByWorkflow.mock.calls[0][0];
402-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
402+
expectDatesClose(callArgs.startDate, sixDaysAgo);
403403
expectDatesClose(callArgs.endDate, today);
404404

405405
expect(response).toEqual({ count: 0, data: [] });
@@ -433,7 +433,7 @@ describe('InsightsController', () => {
433433
});
434434

435435
const callArgs = insightsByPeriodRepository.getInsightsByWorkflow.mock.calls[0][0];
436-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
436+
expectDatesClose(callArgs.startDate, sixDaysAgo);
437437
expectDatesClose(callArgs.endDate, today);
438438

439439
expect(response).toEqual({ count: 3, data: mockRows });
@@ -671,7 +671,7 @@ describe('InsightsController', () => {
671671
});
672672

673673
const callArgs = insightsByPeriodRepository.getInsightsByTime.mock.calls[0][0];
674-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
674+
expectDatesClose(callArgs.startDate, sixDaysAgo);
675675
expectDatesClose(callArgs.endDate, today);
676676

677677
expect(response).toEqual([]);
@@ -694,7 +694,7 @@ describe('InsightsController', () => {
694694
});
695695

696696
const callArgs = insightsByPeriodRepository.getInsightsByTime.mock.calls[0][0];
697-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
697+
expectDatesClose(callArgs.startDate, sixDaysAgo);
698698
expectDatesClose(callArgs.endDate, today);
699699

700700
expect(response).toEqual(expectedResponse);
@@ -740,7 +740,7 @@ describe('InsightsController', () => {
740740
});
741741

742742
const callArgs = insightsByPeriodRepository.getInsightsByTime.mock.calls[0][0];
743-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
743+
expectDatesClose(callArgs.startDate, sixDaysAgo);
744744
expectDatesClose(callArgs.endDate, today);
745745

746746
expect(response).toEqual(expectedResponse);
@@ -887,7 +887,7 @@ describe('InsightsController', () => {
887887
});
888888

889889
const callArgs = insightsByPeriodRepository.getInsightsByTime.mock.calls[0][0];
890-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
890+
expectDatesClose(callArgs.startDate, sixDaysAgo);
891891
expectDatesClose(callArgs.endDate, today);
892892

893893
expect(response).toEqual(expectedResponse);
@@ -912,7 +912,7 @@ describe('InsightsController', () => {
912912
});
913913

914914
const callArgs = insightsByPeriodRepository.getInsightsByTime.mock.calls[0][0];
915-
expectDatesClose(callArgs.startDate, sevenDaysAgo);
915+
expectDatesClose(callArgs.startDate, sixDaysAgo);
916916
expectDatesClose(callArgs.endDate, today);
917917

918918
expect(response).toEqual(expectedResponse);

0 commit comments

Comments
 (0)