@things-factory/dataset 6.0.80 → 6.0.82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/dataset",
3
- "version": "6.0.80",
3
+ "version": "6.0.82",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -36,19 +36,19 @@
36
36
  "@operato/shell": "^1.0.1",
37
37
  "@operato/styles": "^1.0.0",
38
38
  "@operato/utils": "^1.0.1",
39
- "@things-factory/auth-base": "^6.0.78",
40
- "@things-factory/aws-base": "^6.0.78",
41
- "@things-factory/board-service": "^6.0.78",
39
+ "@things-factory/auth-base": "^6.0.82",
40
+ "@things-factory/aws-base": "^6.0.82",
41
+ "@things-factory/board-service": "^6.0.82",
42
42
  "@things-factory/env": "^6.0.78",
43
- "@things-factory/organization": "^6.0.78",
44
- "@things-factory/scheduler-client": "^6.0.78",
45
- "@things-factory/shell": "^6.0.78",
46
- "@things-factory/work-shift": "^6.0.78",
47
- "@things-factory/worklist": "^6.0.78",
43
+ "@things-factory/organization": "^6.0.82",
44
+ "@things-factory/scheduler-client": "^6.0.82",
45
+ "@things-factory/shell": "^6.0.82",
46
+ "@things-factory/work-shift": "^6.0.82",
47
+ "@things-factory/worklist": "^6.0.82",
48
48
  "cron-parser": "^4.3.0",
49
49
  "moment-timezone": "^0.5.40",
50
50
  "simple-statistics": "^7.8.3",
51
51
  "statistics": "^3.3.0"
52
52
  },
53
- "gitHead": "0b02fefdccfc63cbceae281aedb7b0e64e10f337"
53
+ "gitHead": "6cd2a84db2c9ad8d9e75ecbdfcc53df1b20cf79f"
54
54
  }
@@ -110,13 +110,14 @@ async function getLatestTimesForPeriod(
110
110
  const now = moment()
111
111
 
112
112
  if (periodType == DataSetSummaryPeriodType.Hour) {
113
- const begin = now.clone().subtract(1, 'day').startOf('hour').toDate()
114
- const end = now.clone().startOf('hour').toDate()
113
+ const begin = now.clone().subtract(1, 'hour').startOf('hour')
114
+ const end = now.clone().startOf('hour')
115
+ const date = begin.clone().tz(domain.timezone)
115
116
 
116
117
  return {
117
- date: moment(begin).tz(domain.timezone).format('YYYY-MM-DD'),
118
- period: String(begin.getHours()),
119
- range: [begin, end]
118
+ date: date.format('YYYY-MM-DD'),
119
+ period: date.format('HH'),
120
+ range: [begin.toDate(), end.toDate()]
120
121
  }
121
122
  } else if (periodType == DataSetSummaryPeriodType.WorkShift) {
122
123
  const { workDate, workShift, shiftRange } = await getLatestWorkDateAndShift(domain, new Date())
@@ -127,12 +128,13 @@ async function getLatestTimesForPeriod(
127
128
 
128
129
  return { date: workDate, range: dateRange }
129
130
  } else if (periodType == DataSetSummaryPeriodType.Day) {
130
- const begin = now.clone().subtract(1, 'day').startOf('day').toDate()
131
- const end = now.clone().startOf('day').toDate()
131
+ const begin = now.clone().subtract(1, 'day').startOf('day')
132
+ const end = now.clone().startOf('day')
133
+ const date = begin.clone().tz(domain.timezone)
132
134
 
133
135
  return {
134
- date: moment(begin).tz(domain.timezone).format('YYYY-MM-DD'),
135
- range: [begin, end]
136
+ date: date.format('YYYY-MM-DD'),
137
+ range: [begin.toDate(), end.toDate()]
136
138
  }
137
139
  }
138
140
  }
@@ -203,14 +205,18 @@ export async function generateLatestDataSummaries(dataSetId: string, context: Re
203
205
  do {
204
206
  const samples = await getQueryBuilderFromListParams({
205
207
  repository: tx.getRepository(DataSample),
208
+ domain,
206
209
  params: {
207
210
  filters: [{ name: 'dataSetId', operator: 'eq', value: dataSetId }],
208
211
  pagination: { page, limit },
209
212
  sortings: [...buildKeySortingList(dataKeyItems), { name: 'collectedAt', desc: true }]
210
213
  },
211
- domain
214
+ alias: 'datasample'
212
215
  })
213
- .andWhere({ collectedAt: Between.call(range) })
216
+ // The 'Between' operator includes the 'to' time in the filtering, making it unsuitable for the desired use case.
217
+ // .andWhere({ collectedAt: Between.apply(null, range) })
218
+ .andWhere('datasample.collectedAt >= :from', { from: range[0] })
219
+ .andWhere('datasample.collectedAt < :to', { to: range[1] })
214
220
  .getMany()
215
221
 
216
222
  for (const sample of samples) {
@@ -316,11 +322,13 @@ export async function generateDataSummary(
316
322
  pagination: { page, limit },
317
323
  sortings: [...buildKeySortingList(dataKeyItems), { name: 'collectedAt', desc: true }]
318
324
  },
319
- domain
325
+ domain,
326
+ alias: 'datasample'
320
327
  })
321
- .andWhere({
322
- collectedAt: Between.apply(null, range)
323
- })
328
+ // The 'Between' operator includes the 'to' time in the filtering, making it unsuitable for the desired use case.
329
+ // .andWhere({ collectedAt: Between.apply(null, range) })
330
+ .andWhere('datasample.collectedAt >= :from', { from: range[0] })
331
+ .andWhere('datasample.collectedAt < :to', { to: range[1] })
324
332
  .getMany()
325
333
 
326
334
  for (const sample of samples) {