Skip to content

Commit

Permalink
fix: set last state only for incremental syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
am6010 committed Dec 21, 2023
1 parent 19cf201 commit 414716e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator
from source_stripe.streams import (
Accounts,
ApplicationFees,
ApplicationFeesRefunds,
Authorizations,
BalanceTransactions,
BankAccounts,
Expand Down Expand Up @@ -79,8 +77,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
incremental_args = {**args, "lookback_window_days": config.get("lookback_window_days")}
return [
Accounts(**args),
ApplicationFees(**incremental_args),
ApplicationFeesRefunds(**args),
Authorizations(**incremental_args),
BalanceTransactions(**incremental_args),
BankAccounts(**args),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ def shouldFetchFromOriginalResource (self,stream_state = None):
# Fetch data from original stream else fetch data from events
shouldResetState = durationInDaysFromLastSync >= 30
return hasState is False or self.completed is False or shouldResetState
def read_records(self, stream_slice, stream_state = None, **kwargs) -> Iterable[Mapping[str, Any]]:
def read_records(self, stream_slice, stream_state = None, cursor_field= None, **kwargs) -> Iterable[Mapping[str, Any]]:
shouldFetchFromOriginalResource = self.shouldFetchFromOriginalResource(stream_state)
if shouldFetchFromOriginalResource:
self.logger.info("Fetching from original source")
self.setLastSlice(stream_state)
if stream_state:
self.setLastSlice(stream_state)
self.completed = False
yield from self.lookahead(stream_slice, super().read_records(stream_slice=stream_slice, stream_state=None, **kwargs))
else:
Expand Down

0 comments on commit 414716e

Please sign in to comment.