mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(core): Handle infinite max history for insights date range (#14794)
This commit is contained in:
committed by
GitHub
parent
f835c66d98
commit
e83a64b84a
@@ -505,6 +505,22 @@ describe('getAvailableDateRanges', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('returns correct ranges when hourly data is enabled and max history is unlimited', () => {
|
||||||
|
licenseMock.getInsightsMaxHistory.mockReturnValue(-1);
|
||||||
|
licenseMock.isInsightsHourlyDataEnabled.mockReturnValue(true);
|
||||||
|
|
||||||
|
const result = insightsService.getAvailableDateRanges();
|
||||||
|
|
||||||
|
expect(result).toEqual([
|
||||||
|
{ key: 'day', licensed: true, granularity: 'hour' },
|
||||||
|
{ key: 'week', licensed: true, granularity: 'day' },
|
||||||
|
{ key: '2weeks', licensed: true, granularity: 'day' },
|
||||||
|
{ key: 'month', licensed: true, granularity: 'day' },
|
||||||
|
{ key: 'quarter', licensed: true, granularity: 'week' },
|
||||||
|
{ key: 'year', licensed: true, granularity: 'week' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
test('returns correct ranges when hourly data is enabled and max history is 365 days', () => {
|
test('returns correct ranges when hourly data is enabled and max history is 365 days', () => {
|
||||||
licenseMock.getInsightsMaxHistory.mockReturnValue(365);
|
licenseMock.getInsightsMaxHistory.mockReturnValue(365);
|
||||||
licenseMock.isInsightsHourlyDataEnabled.mockReturnValue(true);
|
licenseMock.isInsightsHourlyDataEnabled.mockReturnValue(true);
|
||||||
|
|||||||
@@ -182,7 +182,10 @@ export class InsightsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAvailableDateRanges(): InsightsDateRange[] {
|
getAvailableDateRanges(): InsightsDateRange[] {
|
||||||
const maxHistoryInDays = this.license.getInsightsMaxHistory();
|
const maxHistoryInDays =
|
||||||
|
this.license.getInsightsMaxHistory() === -1
|
||||||
|
? Number.MAX_SAFE_INTEGER
|
||||||
|
: this.license.getInsightsMaxHistory();
|
||||||
const isHourlyDateEnabled = this.license.isInsightsHourlyDataEnabled();
|
const isHourlyDateEnabled = this.license.isInsightsHourlyDataEnabled();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user