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

feat: Use sorted API requests to support crash tolerant incremental sync #32

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tap_klaviyo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def get_url_params(
else:
filter_timestamp = DEFAULT_START_DATE

if self.is_sorted:
params["sort"] = self.replication_key

params["filter"] = f"greater-than({self.replication_key},{filter_timestamp})"

return params
16 changes: 16 additions & 0 deletions tap_klaviyo/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def post_process(
row["datetime"] = row["attributes"]["datetime"]
return row

@property
def is_sorted(self) -> bool:
return True


class CampaignsStream(KlaviyoStream):
"""Define custom stream."""
Expand Down Expand Up @@ -73,6 +77,10 @@ def post_process(
row["updated_at"] = row["attributes"]["updated_at"]
return row

@property
def is_sorted(self) -> bool:
return True


class ProfilesStream(KlaviyoStream):
"""Define custom stream."""
Expand All @@ -91,6 +99,10 @@ def post_process(
row["updated"] = row["attributes"]["updated"]
return row

@property
def is_sorted(self) -> bool:
return True


class MetricsStream(KlaviyoStream):
"""Define custom stream."""
Expand Down Expand Up @@ -175,3 +187,7 @@ def post_process(
) -> dict | None:
row["updated"] = row["attributes"]["updated"]
return row

@property
def is_sorted(self) -> bool:
return True
Loading