@things-factory/dataset 8.0.41 → 8.0.48
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/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/create-data-sample.js +17 -0
- package/dist-server/controllers/create-data-sample.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/controllers/create-data-sample.ts +32 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "8.0.
|
3
|
+
"version": "8.0.48",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -56,5 +56,5 @@
|
|
56
56
|
"simple-statistics": "^7.8.3",
|
57
57
|
"statistics": "^3.3.0"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "93dbef6bdf3361c667f1f9b241e1951eb3227a2e"
|
60
60
|
}
|
@@ -59,11 +59,15 @@ const formatDate = (keys, _moment) => {
|
|
59
59
|
export async function createDataSample(newDataSample: NewDataSample, context: ResolverContext): Promise<DataSample> {
|
60
60
|
const { domain, user, tx } = context.state
|
61
61
|
|
62
|
+
console.log(`[createDataSample 01] start`)
|
63
|
+
|
62
64
|
const dataSet = await getRepository(DataSet, tx).findOne({
|
63
65
|
where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: newDataSample.dataSet.id },
|
64
66
|
relations: ['dataKeySet']
|
65
67
|
})
|
66
68
|
|
69
|
+
console.log(`[createDataSample 02] dataSet : ${JSON.stringify(dataSet)}`)
|
70
|
+
|
67
71
|
const { dataItems = [], tag: publishTag, normalScenarioId, outlierScenarioId } = dataSet
|
68
72
|
const collectedAt = newDataSample.collectedAt || new Date()
|
69
73
|
|
@@ -74,6 +78,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
74
78
|
const { workDate, workShift } = await getWorkDateAndShift(domain, collectedAt, { timezone, format })
|
75
79
|
|
76
80
|
// local time dataSet timezone or domain timezone or default 'UTC'
|
81
|
+
console.log(`[createDataSample 03] workShift : ${JSON.stringify(workShift)}`)
|
77
82
|
|
78
83
|
const localDateTz = moment(collectedAt).tz(timezone)
|
79
84
|
const defaultPartitionKeys = {
|
@@ -90,12 +95,20 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
90
95
|
}
|
91
96
|
|
92
97
|
partitionKeys = formatDate(partitionKeys, localDateTz)
|
98
|
+
console.log(`[createDataSample 04] formatDate : ${JSON.stringify(partitionKeys)}`)
|
99
|
+
|
93
100
|
partitionKeys = replaceVariables(partitionKeys, newDataSample.data)
|
94
101
|
|
102
|
+
console.log(`[createDataSample 05] replaceVariables : ${JSON.stringify(partitionKeys)}`)
|
103
|
+
|
95
104
|
const dataKeys = fillDataKeys(dataSet?.dataKeySet, newDataSample.data)
|
96
105
|
|
106
|
+
console.log(`[createDataSample 06] fillDataKeys : ${JSON.stringify(dataKeys)}`)
|
107
|
+
|
97
108
|
const { ooc, oos, judgment } = DataUseCase.evaluate(dataSet, dataItems, newDataSample.data) || {}
|
98
109
|
|
110
|
+
console.log(`[createDataSample 07] ooc, oos, judgment : ${JSON.stringify({ ooc, oos, judgment })}`)
|
111
|
+
|
99
112
|
const old = await getRepository(DataSample, tx).findOne({
|
100
113
|
where: {
|
101
114
|
domain: { id: domain.id },
|
@@ -105,6 +118,8 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
105
118
|
}
|
106
119
|
})
|
107
120
|
|
121
|
+
console.log(`[createDataSample 08] old : ${JSON.stringify(old)}`)
|
122
|
+
|
108
123
|
/*
|
109
124
|
pre-processing for file attachment.
|
110
125
|
currently only support type of [FileUpload].
|
@@ -114,6 +129,8 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
114
129
|
const data = newDataSample.data
|
115
130
|
const attachments = []
|
116
131
|
|
132
|
+
console.log(`[createDataSample 09] start for item loop`)
|
133
|
+
|
117
134
|
for (let dataItem of dataItems) {
|
118
135
|
if (dataItem.type == 'file') {
|
119
136
|
const tag = dataItem.tag
|
@@ -165,6 +182,8 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
165
182
|
}
|
166
183
|
}
|
167
184
|
|
185
|
+
console.log(`[createDataSample 10] end for item loop`)
|
186
|
+
|
168
187
|
const dataSample = await getRepository(DataSample, tx).save({
|
169
188
|
...old,
|
170
189
|
name: dataSet.name,
|
@@ -186,7 +205,10 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
186
205
|
updater: user
|
187
206
|
})
|
188
207
|
|
208
|
+
console.log(`[createDataSample 11] saved dataSample : ${JSON.stringify(dataSample)}`)
|
209
|
+
|
189
210
|
if (publishTag) {
|
211
|
+
console.log(`[createDataSample 12] publishTag : ${JSON.stringify(publishTag)}`)
|
190
212
|
publishData(publishTag, data, { domain, user })
|
191
213
|
}
|
192
214
|
|
@@ -196,10 +218,14 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
196
218
|
getRepository(Attachment, tx).save(attachments)
|
197
219
|
}
|
198
220
|
|
221
|
+
console.log(`[createDataSample 13] ooc : ${ooc}`)
|
222
|
+
|
199
223
|
if (ooc || oos) {
|
200
224
|
const dataOoc = await createDataOoc(dataSample, dataSet, context)
|
201
225
|
await issueOocReview(dataOoc, dataSet, context)
|
202
226
|
|
227
|
+
console.log(`[createDataSample 14] ooc : ${dataOoc}`)
|
228
|
+
|
203
229
|
try {
|
204
230
|
pubsub.publish('notification', {
|
205
231
|
notification: {
|
@@ -215,6 +241,8 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
215
241
|
logger.error('Notification', err)
|
216
242
|
}
|
217
243
|
} else {
|
244
|
+
console.log(`[createDataSample 15] normalScenarioId : ${normalScenarioId}`)
|
245
|
+
|
218
246
|
if (normalScenarioId) {
|
219
247
|
const scenario = await getRepository(Scenario, tx).findOne({
|
220
248
|
where: {
|
@@ -262,6 +290,8 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
262
290
|
name: 'Data Review'
|
263
291
|
})) as Activity
|
264
292
|
|
293
|
+
console.log(`[createDataSample 16] activity : ${JSON.stringify(activity)}`)
|
294
|
+
|
265
295
|
if (activity) {
|
266
296
|
const assigneeRole =
|
267
297
|
dataSet.supervisoryRoleId &&
|
@@ -319,5 +349,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
319
349
|
}
|
320
350
|
}
|
321
351
|
|
352
|
+
console.log(`[createDataSample 17] end`)
|
353
|
+
|
322
354
|
return dataSample
|
323
355
|
}
|