Skip to content

Commit

Permalink
Fix ContactsSink pagination logic for activist codes
Browse files Browse the repository at this point in the history
  • Loading branch information
butkeraites-hotglue committed Jan 29, 2025
1 parent 339cf45 commit bd01e4c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions target_everyaction/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def _get_or_create_code(self, code_payload: dict) -> Optional[str]:
item["name"].lower(): item["codeId"]
for item in data["items"]
})
if "nextPageLink" not in data:
if "nextPageLink" in data and data["nextPageLink"]:
response = self.request_api("GET",
endpoint=f"codes?{data['nextPageLink'].split('?')[1]}")
else:
break
response = self.request_api("GET",
endpoint=f"codes?{data['nextPageLink'].split('?')[1]}")
else:
break

Expand Down Expand Up @@ -117,13 +118,12 @@ def _get_all_activist_codes(self) -> dict:
for item in data["items"]:
all_codes[item["name"].lower()] = item["activistCodeId"]

# Check if there are more pages
if not data.get("nextPageLink"):
break

# Extract next page URL and make request
next_page = data["nextPageLink"].split("?")[1]
response = self.request_api("GET", endpoint=f"activistCodes?{next_page}")
if "nextPageLink" in data and data["nextPageLink"]:
next_page = data["nextPageLink"].split("?")[1]
response = self.request_api("GET", endpoint=f"activistCodes?{next_page}")
else:
break
else:
break

Expand Down

0 comments on commit bd01e4c

Please sign in to comment.