Skip to content

Commit 4c1d08c

Browse files
committed
fix tasks
1 parent 3bbaada commit 4c1d08c

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/in-queue/entry-types/in-task/in-task.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dateUtils from "../../../utils/date-utils.ts";
66
import type { InSpatialORM } from "../../../orm/inspatial-orm.ts";
77
import { convertString } from "~/utils/mod.ts";
88
import type { EntryName, SettingsName } from "#types/models.ts";
9+
import type { GenericEntry } from "../../../orm/entry/entry-base.ts";
910

1011
const config = {
1112
titleField: "title",
@@ -21,26 +22,26 @@ const config = {
2122
hooks: {
2223
beforeCreate: [{
2324
name: "setTitle",
24-
handler({ entry }: { entry: any }) {
25-
let title = `${convertString(entry.taskType, "title")}: `;
26-
if (entry.typeKey) {
27-
title += `${convertString(entry.typeKey, "title")}`;
25+
handler({ entry }: { entry: GenericEntry }) {
26+
let title = `${convertString(entry.$taskType, "title")}: `;
27+
if (entry.$typeKey) {
28+
title += `${convertString(entry.$typeKey, "title")}`;
2829
}
29-
title += ` - ${entry.actionName}`;
30-
entry.title = title;
30+
title += ` - ${entry.$actionName}`;
31+
entry.$title = title;
3132
},
3233
}],
3334
},
3435
actions: [{
3536
key: "runTask",
3637
params: [],
3738
async action({ entry, inCloud, orm }: {
38-
entry: any;
39+
entry: GenericEntry;
3940
inCloud: any;
4041
orm: InSpatialORM;
4142
}) {
4243
let results;
43-
switch (entry.status) {
44+
switch (entry.$status) {
4445
case "queued":
4546
case "failed":
4647
break;
@@ -50,25 +51,25 @@ const config = {
5051
// const orm = inCloud.orm.withAccount(
5152
// inCloud.orm.systemGobalUser.accountId,
5253
// );
53-
entry.status = "running";
54-
entry.startTime = dateUtils.nowTimestamp();
54+
entry.$status = "running";
55+
entry.$startTime = dateUtils.nowTimestamp();
5556
await entry.save();
5657
try {
57-
switch (entry.taskType) {
58+
switch (entry.$taskType) {
5859
case "entry":
5960
results = await runEntryTask({
60-
actionName: entry.actionName,
61-
entryType: entry.typeKey!,
62-
id: entry.entryId!,
63-
taskData: entry.taskData,
61+
actionName: entry.$actionName,
62+
entryType: entry.$typeKey!,
63+
id: entry.$entryId!,
64+
taskData: entry.$taskData,
6465
orm,
6566
});
6667
break;
6768
case "settings":
6869
results = await runSettingsTask({
69-
actionName: entry.actionName,
70-
settings: entry.typeKey!,
71-
taskData: entry.taskData,
70+
actionName: entry.$actionName,
71+
settings: entry.$typeKey!,
72+
taskData: entry.$taskData,
7273
orm,
7374
});
7475
break;
@@ -77,19 +78,19 @@ const config = {
7778
// break;
7879
}
7980

80-
entry.resultData = {
81+
entry.$resultData = {
8182
result: results,
8283
};
83-
entry.status = "completed";
84+
entry.$status = "completed";
8485
} catch (e) {
85-
entry.errorInfo = Deno.inspect(e);
86+
entry.$errorInfo = Deno.inspect(e);
8687
inCloud.inLog.error(e, {
87-
subject: `${entry.typeKey} ${entry.entryId} - ${entry.actionName}`,
88+
subject: `${entry.$typeKey} ${entry.$entryId} - ${entry.$actionName}`,
8889
stackTrace: e instanceof Error ? e.stack : undefined,
8990
});
90-
entry.status = "failed";
91+
entry.$status = "failed";
9192
}
92-
entry.endTime = dateUtils.nowTimestamp();
93+
entry.$endTime = dateUtils.nowTimestamp();
9394
await entry.save();
9495
},
9596
}],

0 commit comments

Comments
 (0)