diff --git a/mixer/src/etl/index.ts b/mixer/src/etl/index.ts index 733e75c..2b51bd0 100644 --- a/mixer/src/etl/index.ts +++ b/mixer/src/etl/index.ts @@ -38,6 +38,7 @@ export const processChange = async (doc: ChangeRow, api): Promise } const changes = new Set(); + if (doc.table == "events") { if (doc.columns.some(a => a.name == "module" && a.value == "automationTime")) { const rawData = doc.columns.find(a => a.name == "data"); @@ -66,6 +67,15 @@ export const processChange = async (doc: ChangeRow, api): Promise 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); @@ -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) diff --git a/mixer/src/index.ts b/mixer/src/index.ts index 4f742f1..f609d22 100644 --- a/mixer/src/index.ts +++ b/mixer/src/index.ts @@ -75,6 +75,7 @@ const listen = async() => { } const row = JSON.parse(change.data); + await processChange(row, api); } } catch (e) {