feat: Fetch data while considering previously persisted records

This commit is contained in:
Faruk AYDIN
2022-03-24 19:59:33 +03:00
committed by Ömer Faruk Aydın
parent 782dba1f5e
commit 3340bdff4c
3 changed files with 57 additions and 8 deletions

View File

@@ -121,8 +121,26 @@ class Processor {
rawParameters
);
const lastExecutionStep = await step
.$relatedQuery('executionSteps')
.orderBy('created_at', 'desc')
.first();
const lastExecutionStepCratedAt = lastExecutionStep?.dataOut
?.created_at as string;
const flow = (await step.$relatedQuery('flow')) as Flow;
const command = appInstance.triggers[key];
const fetchedData = await command.run();
const startTime = new Date(lastExecutionStepCratedAt || flow.updatedAt);
let fetchedData;
if (this.testRun) {
fetchedData = await command.testRun(startTime);
} else {
fetchedData = await command.run(startTime);
}
return fetchedData;
}