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

chore: look back window of 15 minutes for incremental streams… #199

Merged
merged 1 commit into from
Jul 30, 2024
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
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-salesforce/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk~=0.2", "vcrpy==4.1.1", "pandas"]
MAIN_REQUIREMENTS = ["airbyte-cdk==0.67", "vcrpy==4.1.1", "pandas"]

TEST_REQUIREMENTS = ["pytest~=6.1", "pytest-mock~=3.6", "requests_mock", "connector-acceptance-test", "pytest-timeout"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def transform_empty_string_to_none(instance: Any, schema: Any):
class IncrementalRestSalesforceStream(RestSalesforceStream, ABC):
state_checkpoint_interval = 500
STREAM_SLICE_STEP = 30
LOOKBACK_WINDOW_IN_MINUTES = 15

def __init__(self, replication_key: str, start_date: Optional[str], **kwargs):
super().__init__(**kwargs)
Expand All @@ -600,7 +601,10 @@ def stream_slices(
start, end = (None, None)
now = pendulum.now(tz="UTC")
initial_date = pendulum.parse((stream_state or {}).get(self.cursor_field, self.start_date), tz="UTC")

if self.primary_key:
# If the stream has a primary key, we can use a lookback window to avoid missing records.
# https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T48TASAZ
initial_date = initial_date.subtract(minutes=self.LOOKBACK_WINDOW_IN_MINUTES)
slice_number = 1
while not end == now:
start = initial_date.add(days=(slice_number - 1) * self.STREAM_SLICE_STEP)
Expand Down
Loading