Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB Marketing source - lookback window logic not functioning correctly #3395

Merged
merged 6 commits into from
May 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ def read(self, getter: Callable, params: Mapping[str, Any] = None) -> Iterator:
latest_cursor = None
for record in super().read(getter, params):
cursor = pendulum.parse(record[self.state_pk])
if self._state and self._state >= cursor:
continue
if self._state:
buffer_days = getattr(self, 'buffer_days') + 1 if hasattr(self, 'buffer_days') else 0
Copy link
Contributor

@yevhenii-ldv yevhenii-ldv May 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nitpick) We can declare buffer_days before the loop, and simply replace if self._state and self._state >= cursor: with if self._state and self._state.subtract(days=buffer_days) >= cursor:. It will look prettier, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can move declaring buffer_days from the loop. But we should consider that sometimes self._state is None.

if self._state.subtract(days=buffer_days) >= cursor:
continue
latest_cursor = max(cursor, latest_cursor) if latest_cursor else cursor
yield record

Expand Down