@live-change/task-service 0.9.163 → 0.9.165
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/model.js +29 -0
- package/package.json +4 -4
- package/task.ts +10 -4
package/model.js
CHANGED
|
@@ -102,6 +102,9 @@ const Task = definition.model({
|
|
|
102
102
|
byCauseAndStart: {
|
|
103
103
|
property: ['causeType', 'cause', 'startedAt']
|
|
104
104
|
},
|
|
105
|
+
byCauseAndCreatedAt: {
|
|
106
|
+
property: ['causeType', 'cause', 'createdAt']
|
|
107
|
+
},
|
|
105
108
|
byState: {
|
|
106
109
|
property: ['state']
|
|
107
110
|
},
|
|
@@ -290,6 +293,32 @@ definition.view({
|
|
|
290
293
|
}
|
|
291
294
|
})
|
|
292
295
|
|
|
296
|
+
|
|
297
|
+
definition.view({
|
|
298
|
+
name: 'tasksByCauseAndCreatedAt',
|
|
299
|
+
properties: {
|
|
300
|
+
causeType: {
|
|
301
|
+
type: String
|
|
302
|
+
},
|
|
303
|
+
cause: {
|
|
304
|
+
type: String
|
|
305
|
+
},
|
|
306
|
+
...App.rangeProperties
|
|
307
|
+
},
|
|
308
|
+
returns: {
|
|
309
|
+
type: Array,
|
|
310
|
+
of: {
|
|
311
|
+
type: Task
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
async daoPath(props) {
|
|
315
|
+
const { causeType, cause } = props
|
|
316
|
+
const range = App.extractRange(props)
|
|
317
|
+
return Task.sortedIndexRangePath('byCauseAndCreatedAt', [causeType, cause], range)
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
|
|
293
322
|
definition.view({
|
|
294
323
|
name: 'tasksByRoot',
|
|
295
324
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/task-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.165",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@live-change/framework": "^0.9.
|
|
26
|
-
"@live-change/relations-plugin": "^0.9.
|
|
25
|
+
"@live-change/framework": "^0.9.165",
|
|
26
|
+
"@live-change/relations-plugin": "^0.9.165"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "687dab16bd0c6594544cdab70cd7eecc17bb510c"
|
|
29
29
|
}
|
package/task.ts
CHANGED
|
@@ -201,22 +201,28 @@ function progressCounter(reportProgress) {
|
|
|
201
201
|
const progressFunction = (current, total, action, opts) => {
|
|
202
202
|
currentAcc = current
|
|
203
203
|
totalAcc = total
|
|
204
|
-
reportProgress(currentAcc, totalAcc, action, opts)
|
|
204
|
+
return reportProgress(currentAcc, totalAcc, action, opts)
|
|
205
205
|
}
|
|
206
206
|
progressFunction.increment = (action, by = 1, opts) => {
|
|
207
207
|
currentAcc += by
|
|
208
|
-
progressFunction(currentAcc, totalAcc, action, opts)
|
|
208
|
+
return progressFunction(currentAcc, totalAcc, action, opts)
|
|
209
209
|
}
|
|
210
210
|
progressFunction.incrementTotal = (action, by = 1, opts) => {
|
|
211
211
|
totalAcc += by
|
|
212
|
-
progressFunction(currentAcc, totalAcc, action, opts)
|
|
212
|
+
return progressFunction(currentAcc, totalAcc, action, opts)
|
|
213
|
+
}
|
|
214
|
+
progressFunction.action = (action, opts) => {
|
|
215
|
+
return progressFunction(currentAcc, totalAcc, action, opts)
|
|
216
|
+
}
|
|
217
|
+
progressFunction.done = (opts) => {
|
|
218
|
+
return progressFunction(totalAcc, totalAcc, undefined, opts)
|
|
213
219
|
}
|
|
214
220
|
progressFunction.slice = (sliceSize, factor = 1.0) => {
|
|
215
221
|
const sliceStart = currentAcc
|
|
216
222
|
const sliceEnd = sliceStart + sliceSize
|
|
217
223
|
currentAcc = sliceEnd
|
|
218
224
|
return progressCounter((current, total, action, opts) => {
|
|
219
|
-
progressFunction(sliceStart + Math.min(current, sliceSize) * factor,
|
|
225
|
+
return progressFunction(sliceStart + Math.min(current, sliceSize) * factor,
|
|
220
226
|
sliceEnd + Math.min(total, sliceSize) * factor, action, opts)
|
|
221
227
|
})
|
|
222
228
|
}
|