From ec816e1f5e3393975408a8689ba29c9e851e1f08 Mon Sep 17 00:00:00 2001 From: xacadil <92389481+xacadil@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:30:43 +0500 Subject: [PATCH] Pagination loop fix if progress marked doesnt change due to no data. (#18) --- tap_restaurant365/streams.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tap_restaurant365/streams.py b/tap_restaurant365/streams.py index 9db9c76..f90aedd 100644 --- a/tap_restaurant365/streams.py +++ b/tap_restaurant365/streams.py @@ -40,6 +40,14 @@ def get_next_page_token( start_date = (parser.parse(replication_key_value) + timedelta(seconds=1)) or parser.parse(self.config.get("start_date")) today = datetime.today() + if ( + previous_token + and "token" in previous_token + and previous_token['token'] + and start_date.replace(tzinfo=None) + <= previous_token["token"].replace(tzinfo=None) + ): + start_date = previous_token["token"] + timedelta(days=self.days_delta) next_token = start_date.replace(tzinfo=None) if (today - next_token).days < self.days_delta: