Skip to content

Commit

Permalink
fixed paginator when response has 0 records
Browse files Browse the repository at this point in the history
  • Loading branch information
jlloyd-widen committed Apr 3, 2024
1 parent 7dc9626 commit fcfa120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tap-gainsightpx"
version = "1.0.6"
version = "1.0.7"
description = "`tap-gainsightpx` is a Singer tap for GainsightPX, built with the Meltano Singer SDK."
authors = ["Josh Lloyd"]
keywords = [
Expand Down
15 changes: 8 additions & 7 deletions tap_gainsightpx/paginators.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ def has_more(self, response: Response) -> bool:
total_hits = res.get("totalHits")
records_key = re.findall(r"\$\.(.*)\[\*\]", self._records_jsonpath)[0]

has_more = False
if scroll_id is not None:
self.current_record_count += len(res[records_key])
if total_hits > self.current_record_count:
has_more = True

return has_more
response_record_count = len(res[records_key])
self.current_record_count += response_record_count
if response_record_count == 0 or scroll_id is None:
return False
elif total_hits > self.current_record_count:
return True

return False

def advance(self, response: Response) -> None:
"""Get a new page value and advance the current one."""
Expand Down

0 comments on commit fcfa120

Please sign in to comment.