From c42146cd7f3fdf4165f790e555f36c5b5b22270a Mon Sep 17 00:00:00 2001 From: Michel Grautstueck Date: Wed, 7 Feb 2024 10:51:27 +0100 Subject: [PATCH] Remove shouldBeBar & -LineChart checks --- resources/schema.json | 42 ++++++----------------- routes/notification/shouldBeBarChart.js | 35 ------------------- routes/notification/shouldBeLineChart.js | 43 ------------------------ routes/routes.js | 2 -- 4 files changed, 10 insertions(+), 112 deletions(-) delete mode 100644 routes/notification/shouldBeBarChart.js delete mode 100644 routes/notification/shouldBeLineChart.js diff --git a/resources/schema.json b/resources/schema.json index 92c5c76d..d6116580 100755 --- a/resources/schema.json +++ b/resources/schema.json @@ -27,7 +27,11 @@ "type": "ToolEndpoint", "config": { "endpoint": "notification/logScaleMinValueRequirements", - "fields": ["options.chartType", "options.lineChartOptions.yScaleType", "data"] + "fields": [ + "options.chartType", + "options.lineChartOptions.yScaleType", + "data" + ] }, "priority": { "type": "high", @@ -231,36 +235,7 @@ "fields": ["data"] } }, - "notificationChecks": [ - { - "type": "ToolEndpoint", - "config": { - "endpoint": "notification/shouldBeBarChart", - "fields": ["data", "options.chartType"], - "options": { - "limit": 2 - } - }, - "priority": { - "type": "medium", - "value": 3 - } - }, - { - "type": "ToolEndpoint", - "config": { - "endpoint": "notification/shouldBeLineChart", - "fields": ["data", "options.chartType"], - "options": { - "limit": 40 - } - }, - "priority": { - "type": "medium", - "value": 4 - } - } - ] + "notificationChecks": [] }, "default": "Bar" }, @@ -688,7 +663,10 @@ "type": "ToolEndpoint", "config": { "endpoint": "notification/checkMinValueYAxisLogScale", - "fields": ["options.lineChartOptions.yScaleType", "options.lineChartOptions.minValue"] + "fields": [ + "options.lineChartOptions.yScaleType", + "options.lineChartOptions.minValue" + ] }, "priority": { "type": "high", diff --git a/routes/notification/shouldBeBarChart.js b/routes/notification/shouldBeBarChart.js deleted file mode 100644 index 348fc43f..00000000 --- a/routes/notification/shouldBeBarChart.js +++ /dev/null @@ -1,35 +0,0 @@ -const Joi = require("joi"); - -module.exports = { - method: "POST", - path: "/notification/shouldBeBarChart", - options: { - validate: { - options: { - allowUnknown: true, - }, - payload: Joi.object().required(), - }, - tags: ["api"], - }, - handler: function (request, h) { - try { - const item = request.payload.item; - const options = request.payload.options; - if ( - item.options.chartType === "StackedBar" && - item.data[0].length === options.limit - ) { - return { - message: { - title: "notifications.shouldBeBarChart.title", - body: "notifications.shouldBeBarChart.body", - }, - }; - } - return null; - } catch (err) { - return null; - } - }, -}; diff --git a/routes/notification/shouldBeLineChart.js b/routes/notification/shouldBeLineChart.js deleted file mode 100644 index ca1b07bb..00000000 --- a/routes/notification/shouldBeLineChart.js +++ /dev/null @@ -1,43 +0,0 @@ -const Joi = require("joi"); -const array2d = require("array2d"); -const dateSeries = require("../../helpers/dateSeries.js"); -const getChartTypeForItemAndWidth = - require("../../helpers/chartType.js").getChartTypeForItemAndWidth; - -module.exports = { - method: "POST", - path: "/notification/shouldBeLineChart", - options: { - validate: { - options: { - allowUnknown: true, - }, - payload: Joi.object().required(), - }, - tags: ["api"], - }, - handler: function (request, h) { - try { - const item = request.payload.item; - const options = request.payload.options; - const amountOfRows = array2d.height(item.data); - const chartType = getChartTypeForItemAndWidth(item, 300); - if ( - !(chartType === "line" || chartType === "area") && //only apply this if we don't have a line or area chart already - item.data[0] && - amountOfRows > options.limit && - dateSeries.isDateSeriesData(item.data) - ) { - return { - message: { - title: "notifications.shouldBeLineChart.title", - body: "notifications.shouldBeLineChart.body", - }, - }; - } - return null; - } catch (err) { - return null; - } - }, -}; diff --git a/routes/routes.js b/routes/routes.js index 7c901e8f..1e49ac90 100755 --- a/routes/routes.js +++ b/routes/routes.js @@ -14,8 +14,6 @@ module.exports = [ require("./notification/supportedDateFormat"), require("./notification/unsupportedDateFormat"), require("./notification/unsupportedDateFormatEvents"), - require("./notification/shouldBeBarChart.js"), - require("./notification/shouldBeLineChart.js"), require("./notification/shouldBeBars.js"), require("./notification/tooManyRows.js"), require("./locales.js"),