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

Conversation

vitaliizazmic
Copy link
Contributor

What

Connector didn't pull Insights data from the past 28 days while incremental sync. Insights Streams have loopback logic when it requests data from the API. But additional filter was applied while reading, which caused missing data from the past 28 days. I've added checking to this filter to avoid losing data.

Pre-merge Checklist

  • Run integration tests
  • Publish Docker images

Closes #2828

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.

@vitaliizazmic vitaliizazmic requested a review from sherifnada May 13, 2021 14:19
@@ -154,9 +154,10 @@ def read(self, getter: Callable, params: Mapping[str, Any] = None) -> Iterator:
"""Apply state filter to set of records, update cursor(state) if necessary in the end"""
params = params or {}
latest_cursor = None
buffer_days = getattr(self, 'buffer_days') + 1 if hasattr(self, 'buffer_days') else 0
Copy link
Contributor

@keu keu May 13, 2021

Choose a reason for hiding this comment

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

Suggested change
buffer_days = getattr(self, 'buffer_days') + 1 if hasattr(self, 'buffer_days') else 0
buffer_days = getattr(self, 'buffer_days', -1) + 1

Copy link
Contributor

Choose a reason for hiding this comment

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

@keu, I think the logic will be a little wrong with your changes

Copy link
Contributor

@keu keu May 13, 2021

Choose a reason for hiding this comment

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

@yevhenii-ldv it was a test :) ok, I have updated the suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

@vitaliizazmic I have changed my mind, lets add loop_back=0 to IncrementalStream, and just use normal self.loop_back instead

Copy link
Contributor

@keu keu May 13, 2021

Choose a reason for hiding this comment

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

the problem with the current approach is that base class assumes implementation of its child classes, which actually should be wise versa

Copy link
Contributor

Choose a reason for hiding this comment

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

also my bad, I mean lookback or buffer_days

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

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

just small improvement

@vitaliizazmic vitaliizazmic requested a review from keu May 13, 2021 17:02
@vitaliizazmic
Copy link
Contributor Author

@keu I added requested change, could check it?

@vitaliizazmic
Copy link
Contributor Author

vitaliizazmic commented May 13, 2021

/publish connector=connectors/source-facebook-marketing

🕑 connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/839974544
✅ connectors/source-facebook-marketing https://github.com/airbytehq/airbyte/actions/runs/839974544

@vitaliizazmic vitaliizazmic merged commit 3be2a6b into master May 13, 2021
@vitaliizazmic vitaliizazmic deleted the vitalii/2828_fb_marketing_lookback_window branch May 13, 2021 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FB Marketing: lookback window logic not functioning correctly
5 participants