Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Vargas <jvargas@gitlab.com>2019-04-01 21:38:26 +0300
committerJose Vargas <jvargas@gitlab.com>2019-04-04 23:53:03 +0300
commit217e9e4db1a81125a06830b9dbf270a15fb9c284 (patch)
tree212cb0aeb4bf88ce0317b2b8a0e991657fc738b8 /app/assets/javascripts/monitoring/utils.js
parentb75e03a6c95d58a9ce0536da314d782c4895ae43 (diff)
Created `getTimeDiff` utility function
Updated i18n strings and changed the monitoring service graph data params
Diffstat (limited to 'app/assets/javascripts/monitoring/utils.js')
-rw-r--r--app/assets/javascripts/monitoring/utils.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/app/assets/javascripts/monitoring/utils.js b/app/assets/javascripts/monitoring/utils.js
index 1dd26f62437..c3e854c5367 100644
--- a/app/assets/javascripts/monitoring/utils.js
+++ b/app/assets/javascripts/monitoring/utils.js
@@ -1,32 +1,30 @@
-import { timeWindows } from './constants';
+import { timeWindows, msPerMinute } from './constants';
export const getTimeDifferenceMinutes = timeWindow => {
- let timeDifferenceMinutes;
switch (timeWindow) {
case timeWindows.thirtyMinutes:
- timeDifferenceMinutes = 30;
- break;
+ return 30;
case timeWindows.threeHours:
- timeDifferenceMinutes = 60 * 3;
- break;
+ return 60 * 3;
case timeWindows.eightHours:
- timeDifferenceMinutes = 60 * 8;
- break;
+ return 60 * 8;
case timeWindows.oneDay:
- timeDifferenceMinutes = 60 * 24 * 1;
- break;
+ return 60 * 24 * 1;
case timeWindows.threeDays:
- timeDifferenceMinutes = 60 * 24 * 3;
- break;
+ return 60 * 24 * 3;
case timeWindows.oneWeek:
- timeDifferenceMinutes = 60 * 24 * 7 * 1;
- break;
+ return 60 * 24 * 7 * 1;
default:
- timeDifferenceMinutes = 60 * 8;
- break;
+ return 60 * 8;
}
+};
+
+export const getTimeDiff = selectedTimeWindow => {
+ const end = Date.now();
+ const timeDifferenceMinutes = getTimeDifferenceMinutes(selectedTimeWindow);
+ const start = new Date(end - timeDifferenceMinutes * msPerMinute).getTime();
- return timeDifferenceMinutes;
+ return { start, end };
};
export default {};