Skip to content

Commit

Permalink
fix state check (#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalenge authored Dec 11, 2024
1 parent 9aef880 commit 61bb7f9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions sources/tromzo-source/src/streams/findings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ export class Findings extends AirbyteStreamBase {
const currentState = Utils.toDate(
currentStreamState?.[streamSlice.tool]?.cutoff
);
const cutoff =
latestRecordCutoff > currentState ? latestRecordCutoff : currentState;
return {
...currentStreamState,
[streamSlice.tool]: {
cutoff: cutoff.getTime(),
},
};
if (!latestRecordCutoff) {
return currentStreamState;
}

if (currentState && latestRecordCutoff.getTime() > currentState.getTime()) {
return {
...currentStreamState,
[streamSlice.tool]: {
cutoff: latestRecordCutoff.getTime(),
},
};
}

return currentStreamState;
}

private getUpdateRange(cutoff?: number): [Date, Date] {
Expand Down

0 comments on commit 61bb7f9

Please sign in to comment.