Skip to content

Commit

Permalink
Fix not populating tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n committed Dec 19, 2023
1 parent a239f03 commit 6437d17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mixer/src/etl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const processChange = async (doc: ChangeRow, api): Promise<void|string[]>
}

const changes = new Set<string>();

if (doc.table == "events") {
if (doc.columns.some(a => a.name == "module" && a.value == "automationTime")) {
const rawData = doc.columns.find(a => a.name == "data");
Expand Down Expand Up @@ -66,6 +67,15 @@ export const processChange = async (doc: ChangeRow, api): Promise<void|string[]>
const blockHash = doc.columns.find(c => c.name == "hash")?.value;
const blockId = doc.columns.find(c => c.name == "id")?.value
await populateBlockMetadata(blockHash, blockId, api)

// task need to be populated first
await populateTask();
// Now we can update the status and metrics
await Promise.all([
updateTaskStatus(TaskStatus.Completed),
updateTaskStatus(TaskStatus.Canceled),
updateTaskMetric(data.taskId)
]);
}

return Array.from(changes);
Expand Down Expand Up @@ -124,6 +134,7 @@ export const populateTask = async() => {
`;

try {
//await client.query(query,[TaskStatus.Active]);
await client.query(query,[TaskStatus.Active]);
} catch (e) {
console.log("error when populating task", e, query)
Expand Down
1 change: 1 addition & 0 deletions mixer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const listen = async() => {
}

const row = JSON.parse(change.data);

await processChange(row, api);
}
} catch (e) {
Expand Down

0 comments on commit 6437d17

Please sign in to comment.