From b0545e523b3aeb90cd7755d792fed6369c5e03c0 Mon Sep 17 00:00:00 2001 From: harshithmullapudi Date: Wed, 29 Sep 2021 21:21:29 +0530 Subject: [PATCH] Review changes --- .../source-amazon-ads/source_amazon_ads/source.py | 5 +++-- .../connectors/source-amazon-ads/source_amazon_ads/spec.py | 1 + .../streams/report_streams/report_streams.py | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/source.py b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/source.py index 6d395a858278..91d854b142db 100644 --- a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/source.py +++ b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/source.py @@ -131,5 +131,6 @@ def _make_authenticator(config: AmazonAdsConfig): @staticmethod def _choose_profiles(config: AmazonAdsConfig, profiles: List[Profile]): - print(config.profiles) - return filter(lambda profile: profile.profileId in config.profiles, profiles) \ No newline at end of file + if not config.profiles: + return profiles + return filter(lambda profile: profile.profileId in config.profiles, profiles) diff --git a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/spec.py b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/spec.py index cbb27ca00d76..18467f398d33 100644 --- a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/spec.py +++ b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/spec.py @@ -67,6 +67,7 @@ class Config: region: AmazonAdsRegion = Field( name="Region", description="Region to pull data from", + default=AmazonAdsRegion.NA ) profiles: List[int] = Field( diff --git a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/streams/report_streams/report_streams.py b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/streams/report_streams/report_streams.py index ed9c8c2cf7a3..f7daa059e61c 100644 --- a/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/streams/report_streams/report_streams.py +++ b/airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/streams/report_streams/report_streams.py @@ -257,6 +257,9 @@ def get_report_date_ranges(start_report_date: Optional[datetime]) -> Iterable[st def stream_slices( self, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None ) -> Iterable[Optional[Mapping[str, Any]]]: + # Amazon ads updates the data for the next 3 days + LOOK_BACK_WINDOW = 3 + if sync_mode == SyncMode.full_refresh: # For full refresh stream use date from config start_date field. start_date = self._start_date @@ -266,8 +269,7 @@ def stream_slices( start_date = stream_state.get(self.cursor_field) if start_date: start_date = pendulum.from_format(start_date, ReportStream.REPORT_DATE_FORMAT, tz="UTC") - # Amazon ads updates the data for the next 3 days - start_date += timedelta(days=-3) + start_date += timedelta(days=-LOOK_BACK_WINDOW) else: start_date = self._start_date