Skip to content

Commit

Permalink
[mandiant] Fix also work processing
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Aug 30, 2024
1 parent a48aa63 commit bc4df53
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions external-import/mandiant/src/connector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ def run(self):
start_short_format = start_date.short_format

# Fix problem when end state is in the future
if Timestamp.from_iso(state[collection][STATE_END]).value > Timestamp.now().value:
if (
Timestamp.from_iso(state[collection][STATE_END]).value
> Timestamp.now().value
):
state[collection][STATE_END] = None

# If no end date, put the proper period using delta
Expand Down Expand Up @@ -680,12 +683,25 @@ def _run(
will also be updated to before_process_now to be used as a marker.
"""
before_process_now = Timestamp.now()

start = Timestamp.from_iso(state[collection][STATE_START])
end = (
Timestamp.from_iso(state[collection][STATE_END])
if state[collection][STATE_END] is not None
else None
)

# Fix problem when end state is in the future
if (
Timestamp.from_iso(state[collection][STATE_END]).value
> Timestamp.now().value
):
state[collection][STATE_END] = None

# If no end date, put the proper period using delta
if state[collection][STATE_END] is None:
end = start.delta(days=self.mandiant_import_period)
# If delta is in the future, limit to today
if end.value > Timestamp.now().value:
end = Timestamp.now()
else:
end = Timestamp.from_iso(state[collection][STATE_END])

offset = state[collection][STATE_OFFSET]

parameters = {}
Expand Down

0 comments on commit bc4df53

Please sign in to comment.