|
|
@ -283,19 +283,12 @@ module.exports = function(state) {
|
|
|
|
return Promise.try(() => {
|
|
|
|
return Promise.try(() => {
|
|
|
|
return getTaskResult(tx, task, id);
|
|
|
|
return getTaskResult(tx, task, id);
|
|
|
|
}).then((taskResult) => {
|
|
|
|
}).then((taskResult) => {
|
|
|
|
let sharedFields = {
|
|
|
|
|
|
|
|
isInvalidated: false,
|
|
|
|
|
|
|
|
updatedAt: new Date()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskResult != null) {
|
|
|
|
if (taskResult != null) {
|
|
|
|
return taskResult.$query(tx).patch({
|
|
|
|
return taskResult.$query(tx).patch({
|
|
|
|
... sharedFields,
|
|
|
|
|
|
|
|
metadata: update(taskResult.metadata),
|
|
|
|
metadata: update(taskResult.metadata),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return db.TaskResult.query(tx).insert({
|
|
|
|
return db.TaskResult.query(tx).insert({
|
|
|
|
... sharedFields,
|
|
|
|
|
|
|
|
task: task.name,
|
|
|
|
task: task.name,
|
|
|
|
itemId: id,
|
|
|
|
itemId: id,
|
|
|
|
metadata: update({})
|
|
|
|
metadata: update({})
|
|
|
@ -333,7 +326,9 @@ module.exports = function(state) {
|
|
|
|
}).then((taskResult) => {
|
|
|
|
}).then((taskResult) => {
|
|
|
|
let sharedFields = {
|
|
|
|
let sharedFields = {
|
|
|
|
isSuccessful: isSuccessful,
|
|
|
|
isSuccessful: isSuccessful,
|
|
|
|
|
|
|
|
isInvalidated: false,
|
|
|
|
taskVersion: task.version,
|
|
|
|
taskVersion: task.version,
|
|
|
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
expiresAt: (task.ttl != null)
|
|
|
|
expiresAt: (task.ttl != null)
|
|
|
|
? addMilliseconds(new Date(), task.ttl)
|
|
|
|
? addMilliseconds(new Date(), task.ttl)
|
|
|
|
: undefined
|
|
|
|
: undefined
|
|
|
|