From d8f37ca1b405782b0942cf34d3fb4c5cb1b586dc Mon Sep 17 00:00:00 2001 From: ReubenFrankel <60552974+ReubenFrankel@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:51:14 +0100 Subject: [PATCH] fix: Ineligible customers are now skipped properly (#64) * Missing `return` statements * Respect both `customer_ids`/`customer_id`from config when generating child contexts --- tap_googleads/client.py | 8 +++++--- tap_googleads/streams.py | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tap_googleads/client.py b/tap_googleads/client.py index a3eb9fe..68d90f3 100644 --- a/tap_googleads/client.py +++ b/tap_googleads/client.py @@ -119,7 +119,9 @@ def end_date(self): @cached_property def customer_ids(self): - if self.config.get("customer_ids"): - return self.config["customer_ids"] + customer_ids = self.config.get("customer_ids") + if customer_ids is not None: + return customer_ids - return [self.config["customer_id"]] if self.config.get("customer_id") else [] \ No newline at end of file + customer_id = self.config.get("customer_id") + return customer_id and [customer_id] \ No newline at end of file diff --git a/tap_googleads/streams.py b/tap_googleads/streams.py index 19c7bef..5291384 100644 --- a/tap_googleads/streams.py +++ b/tap_googleads/streams.py @@ -108,7 +108,7 @@ def validate_response(self, response): super().validate_response(response) def generate_child_contexts(self, record, context): - customer_ids = self.config.get("customer_ids") + customer_ids = self.customer_ids if customer_ids is None: customer = record["customerClient"] @@ -118,12 +118,14 @@ def generate_child_contexts(self, record, context): "%s is a manager, skipping", customer["clientCustomer"], ) + return if customer["status"] != "ENABLED": self.logger.warning( "%s is not enabled, skipping", customer["clientCustomer"], ) + return customer_ids = {customer["id"]}