mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 13:59:02 +08:00
refactor: added 3 days global timestamp (#4290)
* refactor: added 3 days global timestamp * refactor: updated 3 days data in right container * refactor: common function for calculate start and end time
This commit is contained in:
parent
3572baa5eb
commit
cfc239e3c9
@ -28,6 +28,10 @@ export const timeItems: timePreferance[] = [
|
||||
name: 'Last 1 day',
|
||||
enum: 'LAST_1_DAY',
|
||||
},
|
||||
{
|
||||
name: 'Last 3 days',
|
||||
enum: 'LAST_3_DAYS',
|
||||
},
|
||||
{
|
||||
name: 'Last 1 week',
|
||||
enum: 'LAST_1_WEEK',
|
||||
@ -47,6 +51,7 @@ export type timePreferenceType =
|
||||
| LAST_1_HR
|
||||
| LAST_6_HR
|
||||
| LAST_1_DAY
|
||||
| LAST_3_DAYS
|
||||
| LAST_1_WEEK;
|
||||
|
||||
type GLOBAL_TIME = 'GLOBAL_TIME';
|
||||
@ -56,6 +61,7 @@ type LAST_30_MIN = 'LAST_30_MIN';
|
||||
type LAST_1_HR = 'LAST_1_HR';
|
||||
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';
|
||||
|
||||
export default timeItems;
|
||||
|
@ -9,6 +9,7 @@ type SixHour = '6hr';
|
||||
type OneHour = '1hr';
|
||||
type FourHour = '4hr';
|
||||
type OneDay = '1day';
|
||||
type ThreeDay = '3days';
|
||||
type OneWeek = '1week';
|
||||
type Custom = 'custom';
|
||||
|
||||
@ -23,7 +24,8 @@ export type Time =
|
||||
| OneHour
|
||||
| Custom
|
||||
| OneWeek
|
||||
| OneDay;
|
||||
| OneDay
|
||||
| ThreeDay;
|
||||
|
||||
export const Options: Option[] = [
|
||||
{ value: '5min', label: 'Last 5 min' },
|
||||
@ -32,6 +34,7 @@ export const Options: Option[] = [
|
||||
{ value: '1hr', label: 'Last 1 hour' },
|
||||
{ value: '6hr', label: 'Last 6 hour' },
|
||||
{ value: '1day', label: 'Last 1 day' },
|
||||
{ value: '3days', label: 'Last 3 days' },
|
||||
{ value: '1week', label: 'Last 1 week' },
|
||||
{ value: 'custom', label: 'Custom' },
|
||||
];
|
||||
@ -48,6 +51,7 @@ export const RelativeDurationOptions: Option[] = [
|
||||
{ value: '1hr', label: 'Last 1 hour' },
|
||||
{ value: '6hr', label: 'Last 6 hour' },
|
||||
{ value: '1day', label: 'Last 1 day' },
|
||||
{ value: '3days', label: 'Last 3 days' },
|
||||
{ value: '1week', label: 'Last 1 week' },
|
||||
];
|
||||
|
||||
|
@ -6,6 +6,7 @@ import getMinAgo from './getStartAndEndTime/getMinAgo';
|
||||
const GetMinMax = (
|
||||
interval: Time,
|
||||
dateTimeRange?: [number, number],
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): GetMinMaxPayload => {
|
||||
let maxTime = new Date().getTime();
|
||||
let minTime = 0;
|
||||
@ -32,6 +33,10 @@ const GetMinMax = (
|
||||
// one day = 24*60(min)
|
||||
const minTimeAgo = getMinAgo({ minutes: 24 * 60 }).getTime();
|
||||
minTime = minTimeAgo;
|
||||
} else if (interval === '3days') {
|
||||
// three day = one day * 3
|
||||
const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 3 }).getTime();
|
||||
minTime = minTimeAgo;
|
||||
} else if (interval === '1week') {
|
||||
// one week = one day * 7
|
||||
const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 7 }).getTime();
|
||||
|
@ -3,6 +3,19 @@ import { timePreferenceType } from 'container/NewWidget/RightContainer/timeItems
|
||||
import getMicroSeconds from './getMicroSeconds';
|
||||
import getMinAgo from './getMinAgo';
|
||||
|
||||
const calculateStartAndEndTime = (
|
||||
minutes: number,
|
||||
endString: string,
|
||||
): Payload => {
|
||||
const agodate = getMinAgo({ minutes }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agodate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
};
|
||||
|
||||
const GetStartAndEndTime = ({
|
||||
type,
|
||||
minTime,
|
||||
@ -12,73 +25,35 @@ const GetStartAndEndTime = ({
|
||||
const endString = getMicroSeconds({ time: end });
|
||||
|
||||
if (type === 'LAST_5_MIN') {
|
||||
const agodate = getMinAgo({ minutes: 5 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agodate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(5, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_30_MIN') {
|
||||
const agodate = getMinAgo({ minutes: 30 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agodate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(30, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_1_HR') {
|
||||
const agodate = getMinAgo({ minutes: 60 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agodate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(60, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_15_MIN') {
|
||||
const agodate = getMinAgo({ minutes: 15 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agodate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(15, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_6_HR') {
|
||||
const agoDate = getMinAgo({ minutes: 6 * 60 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agoDate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(6 * 60, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_1_DAY') {
|
||||
const agoDate = getMinAgo({ minutes: 24 * 60 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agoDate });
|
||||
return calculateStartAndEndTime(24 * 60, endString);
|
||||
}
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
if (type === 'LAST_3_DAYS') {
|
||||
return calculateStartAndEndTime(24 * 60 * 3, endString);
|
||||
}
|
||||
|
||||
if (type === 'LAST_1_WEEK') {
|
||||
const agoDate = getMinAgo({ minutes: 24 * 60 * 7 }).getTime();
|
||||
const agoString = getMicroSeconds({ time: agoDate });
|
||||
|
||||
return {
|
||||
start: agoString,
|
||||
end: endString,
|
||||
};
|
||||
return calculateStartAndEndTime(24 * 60 * 7, endString);
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user