@things-factory/dataset 6.0.85 → 6.0.86
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.
- package/client/pages/data-summary/data-summary-period-page.ts +15 -4
- package/dist-client/pages/data-summary/data-summary-period-page.js +12 -2
- package/dist-client/pages/data-summary/data-summary-period-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/query-data-summary-by-period.js +17 -9
- package/dist-server/controllers/query-data-summary-by-period.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/controllers/query-data-summary-by-period.ts +16 -9
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "6.0.
|
3
|
+
"version": "6.0.86",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"simple-statistics": "^7.8.3",
|
51
51
|
"statistics": "^3.3.0"
|
52
52
|
},
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "b6e098a058696832178dd425ec0893ca4c313b33"
|
54
54
|
}
|
@@ -91,12 +91,17 @@ export async function queryDataSummaryByPeriod(
|
|
91
91
|
|
92
92
|
const { from, to } = await getTimesForPeriod(period, context)
|
93
93
|
|
94
|
-
const selectPeriod =
|
95
|
-
period == 'today'
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
const selectPeriod = queryBuilder => {
|
95
|
+
if (period == 'today') {
|
96
|
+
queryBuilder.addSelect('summary.date', 'date').addSelect('summary.period', 'period')
|
97
|
+
} else if (['this year', '12 months'].includes(period)) {
|
98
|
+
queryBuilder.addSelect('SUBSTRING(summary.date, 1, 7) AS month')
|
99
|
+
} else {
|
100
|
+
queryBuilder.addSelect('summary.date', 'date')
|
101
|
+
}
|
102
|
+
|
103
|
+
return queryBuilder
|
104
|
+
}
|
100
105
|
const selectKeys = dataKeyItems.map((item, index) => {
|
101
106
|
const aliasName = `key0${index + 1}`
|
102
107
|
const columnName = `summary.${aliasName}`
|
@@ -172,20 +177,22 @@ export async function queryDataSummaryByPeriod(
|
|
172
177
|
.select('summary.dataSet')
|
173
178
|
.addSelect('ds.name', 'name')
|
174
179
|
.addSelect('ds.description', 'description')
|
175
|
-
.addSelect('summary.date', 'date')
|
176
|
-
.addSelect('summary.period', 'period')
|
177
|
-
.addSelect(selectPeriod)
|
178
180
|
.addSelect(selectKeys)
|
179
181
|
.addSelect(selectData)
|
180
182
|
.addSelect('SUM(summary.count)', 'count')
|
181
183
|
.addSelect('SUM(summary.countOoc)', 'countOoc')
|
182
184
|
.addSelect('SUM(summary.countOos)', 'countOos')
|
185
|
+
|
186
|
+
selectPeriod(queryBuilder)
|
183
187
|
.innerJoin('summary.dataSet', 'ds', 'ds.id = :dataSetName', {
|
184
188
|
dataSetName: dataSet.id
|
185
189
|
})
|
186
190
|
.andWhere('summary.domain = :domain', { domain: domain.id })
|
187
191
|
.andWhere('summary.date >= :from', { from })
|
188
192
|
.andWhere('summary.date < :to', { to })
|
193
|
+
.addGroupBy('summary.dataSet')
|
194
|
+
.addGroupBy('ds.name')
|
195
|
+
.addGroupBy('ds.description')
|
189
196
|
.addGroupBy(groupByPeriod)
|
190
197
|
.addGroupBy(groupByKeys)
|
191
198
|
|