feat: add 1 month option in time range (#5639)

This commit is contained in:
Yunus M 2024-08-05 16:57:24 +05:30 committed by GitHub
parent f9d1494657
commit 61e6316736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 1 deletions

View File

@ -36,6 +36,10 @@ export const timeItems: timePreferance[] = [
name: 'Last 1 week',
enum: 'LAST_1_WEEK',
},
{
name: 'Last 1 month',
enum: 'LAST_1_MONTH',
},
];
export interface timePreferance {
@ -52,7 +56,8 @@ export type timePreferenceType =
| LAST_6_HR
| LAST_1_DAY
| LAST_3_DAYS
| LAST_1_WEEK;
| LAST_1_WEEK
| LAST_1_MONTH;
type GLOBAL_TIME = 'GLOBAL_TIME';
type LAST_5_MIN = 'LAST_5_MIN';
@ -63,5 +68,6 @@ type LAST_6_HR = 'LAST_6_HR';
type LAST_1_DAY = 'LAST_1_DAY';
type LAST_3_DAYS = 'LAST_3_DAYS';
type LAST_1_WEEK = 'LAST_1_WEEK';
type LAST_1_MONTH = 'LAST_1_MONTH';
export default timeItems;

View File

@ -19,6 +19,7 @@ type TenDay = '10d';
type OneWeek = '1w';
type TwoWeek = '2w';
type SixWeek = '6w';
type OneMonth = '1month';
type TwoMonths = '2months';
type Custom = 'custom';
@ -42,6 +43,7 @@ export type Time =
| TwelveHour
| TenDay
| TwoWeek
| OneMonth
| TwoMonths;
export type TimeUnit = 'm' | 'h' | 'd' | 'w';
@ -57,6 +59,7 @@ export const Options: Option[] = [
{ value: '1d', label: 'Last 1 day' },
{ value: '3d', label: 'Last 3 days' },
{ value: '1w', label: 'Last 1 week' },
{ value: '1month', label: 'Last 1 month' },
{ value: 'custom', label: 'Custom' },
];
@ -95,6 +98,7 @@ export const RelativeDurationOptions: Option[] = [
{ value: '1d', label: 'Last 1 day' },
{ value: '3d', label: 'Last 3 days' },
{ value: '1w', label: 'Last 1 week' },
{ value: '1month', label: 'Last 1 month' },
];
export const RelativeDurationSuggestionOptions: Option[] = [

View File

@ -99,6 +99,10 @@ const GetMinMax = (
// six week = one day * 42
const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 42 }).getTime();
minTime = minTimeAgo;
} else if (interval === '1month') {
// one month = one day * 30
const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 30 }).getTime();
minTime = minTimeAgo;
} else if (interval === '2months') {
// two months = one day * 60
const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 60 }).getTime();

View File

@ -56,6 +56,10 @@ const GetStartAndEndTime = ({
return calculateStartAndEndTime(24 * 60 * 7, endString);
}
if (type === 'LAST_1_MONTH') {
return calculateStartAndEndTime(24 * 60 * 30, endString);
}
return {
start: getMicroSeconds({ time: minTime / 1000000 }),
end: getMicroSeconds({ time: maxTime / 1000000 }),