summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/monitoring/stores/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/monitoring/stores/utils.js')
-rw-r--r--app/assets/javascripts/monitoring/stores/utils.js35
1 files changed, 32 insertions, 3 deletions
diff --git a/app/assets/javascripts/monitoring/stores/utils.js b/app/assets/javascripts/monitoring/stores/utils.js
index a212e9be703..9f06d18c46f 100644
--- a/app/assets/javascripts/monitoring/stores/utils.js
+++ b/app/assets/javascripts/monitoring/stores/utils.js
@@ -58,6 +58,31 @@ export const parseEnvironmentsResponse = (response = [], projectPath) =>
});
/**
+ * Annotation API returns time in UTC. This method
+ * converts time to local time.
+ *
+ * startingAt always exists but endingAt does not.
+ * If endingAt does not exist, a threshold line is
+ * drawn.
+ *
+ * If endingAt exists, a threshold range is drawn.
+ * But this is not supported as of %12.10
+ *
+ * @param {Array} response annotations response
+ * @returns {Array} parsed responses
+ */
+export const parseAnnotationsResponse = response => {
+ if (!response) {
+ return [];
+ }
+ return response.map(annotation => ({
+ ...annotation,
+ startingAt: new Date(annotation.startingAt),
+ endingAt: annotation.endingAt ? new Date(annotation.endingAt) : null,
+ }));
+};
+
+/**
* Maps metrics to its view model
*
* This function difers from other in that is maps all
@@ -95,15 +120,19 @@ const mapXAxisToViewModel = ({ name = '' }) => ({ name });
/**
* Maps Y-axis view model
*
- * Defaults to a 2 digit precision and `number` format. It only allows
+ * Defaults to a 2 digit precision and `engineering` format. It only allows
* formats in the SUPPORTED_FORMATS array.
*
* @param {Object} axis
*/
-const mapYAxisToViewModel = ({ name = '', format = SUPPORTED_FORMATS.number, precision = 2 }) => {
+const mapYAxisToViewModel = ({
+ name = '',
+ format = SUPPORTED_FORMATS.engineering,
+ precision = 2,
+}) => {
return {
name,
- format: SUPPORTED_FORMATS[format] || SUPPORTED_FORMATS.number,
+ format: SUPPORTED_FORMATS[format] || SUPPORTED_FORMATS.engineering,
precision,
};
};