Skip to content

Commit

Permalink
fix: Ineligible customers are now skipped properly (#64)
Browse files Browse the repository at this point in the history
* Missing `return` statements

* Respect both `customer_ids`/`customer_id`from config when generating child contexts
  • Loading branch information
ReubenFrankel authored Oct 22, 2024
1 parent 19c5e98 commit d8f37ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tap_googleads/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
customer_id = self.config.get("customer_id")
return customer_id and [customer_id]
4 changes: 3 additions & 1 deletion tap_googleads/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]}

Expand Down

0 comments on commit d8f37ca

Please sign in to comment.