@isoftdata/utility-dashboard-backend 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +18 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -32,16 +32,14 @@ const handleChartTypeSpecificQuirks = (chartType, resultSet) => {
32
32
  }
33
33
 
34
34
  const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, parameters, ...theRest }) => { // needs database connection
35
- const dataTable = await loadDataTable(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper.chartType })
36
-
37
- const proccessedFormatting = handleFormattingTemplates(formatting)
35
+ const { dataTable, processedFormatting } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper.chartType })
38
36
 
39
37
  if (chartWrapper.chartType === 'Table') {
40
38
  return {
41
39
  ...theRest,
42
40
  chartWrapper,
43
41
  table: dataTable,
44
- formatting: proccessedFormatting,
42
+ formatting: processedFormatting,
45
43
  }
46
44
  }
47
45
  return {
@@ -50,7 +48,7 @@ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatt
50
48
  ...chartWrapper,
51
49
  dataTable,
52
50
  },
53
- formatting: proccessedFormatting,
51
+ formatting: processedFormatting,
54
52
  }
55
53
  }
56
54
  /*
@@ -58,25 +56,25 @@ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatt
58
56
  * Otherwise, it will return data in the google chart Datatable object literal format.
59
57
  * multiSeries, formatting properties should be deconstructed from the chart object, chartType should be deconstructed from the chart's chartWrapper property
60
58
  */
61
- const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
59
+ const loadDataTableAndProcessedFormatting = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
62
60
  let { results: queryResultSet, fields } = (queryObject && queryObject.sql) ? await queryWithFields(mysqlConnection, queryObject) : { fields: [], results: [] }
63
61
  let data = handleChartTypeSpecificQuirks(chartType, queryResultSet)
64
62
 
65
- const proccessedFormatting = handleFormattingTemplates(formatting)
66
-
67
- if (chartType.toLowerCase() === 'table') {
68
- return getRactiveTableDataFormat(data, fields, proccessedFormatting)
69
- }
70
-
71
63
  if (multiSeries) {
72
64
  ({ data, formatting, fields } = getMultiSeriesData({
73
65
  data,
74
66
  seriesOptions: multiSeries,
75
- formatting: proccessedFormatting,
67
+ formatting,
76
68
  fields,
77
69
  }))
78
70
  }
79
71
 
72
+ const processedFormatting = handleFormattingTemplates(formatting)
73
+
74
+ if (chartType.toLowerCase() === 'table') {
75
+ return { dataTable: getRactiveTableDataFormat(data, fields, processedFormatting), processedFormatting }
76
+ }
77
+
80
78
  let dataTable = getDataTableFormat(data, fields, multiSeries) //per the Google Charts docs, the DataTable object literal format is the most performant, so we'll turn it into that format before returning
81
79
 
82
80
  // Stacked area charts will have holes / jagged lines if there are nulls in the middle of a column
@@ -85,9 +83,13 @@ const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries,
85
83
  dataTable = makeDataCumulative(dataTable)
86
84
  }
87
85
 
88
- return dataTable
86
+ return { dataTable, processedFormatting }
89
87
  }
90
88
 
89
+ const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
90
+ const { dataTable } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType })
91
+ return dataTable
92
+ }
91
93
  const loadOptionList = async(mysqlConnection, optionListQuery, optionList = []) => {
92
94
  return [
93
95
  ...optionList,
@@ -206,5 +208,7 @@ module.exports = {
206
208
  },
207
209
  loadOutputParameterValues,
208
210
  loadDataTable,
211
+ loadDataTableAndProcessedFormatting,
209
212
  parameterizeQuery,
213
+ handleFormattingTemplates,
210
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/utility-dashboard-backend",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "A utility for formatting chart and report data to be usable by the frontend dashboard component.",
5
5
  "main": "index.js",
6
6
  "scripts": {