From 622e9b0c314d7e8c51abd9c848a6bc4e125f442e Mon Sep 17 00:00:00 2001 From: Keyna Rafael <95432445+keyn4@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:14:41 -0500 Subject: [PATCH] not write partitions to state, fix get_starting_time (#28) --- tap_restaurant365/client.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tap_restaurant365/client.py b/tap_restaurant365/client.py index 2fa06d4..cf42d85 100644 --- a/tap_restaurant365/client.py +++ b/tap_restaurant365/client.py @@ -15,6 +15,8 @@ from singer_sdk.pagination import BaseAPIPaginator # noqa: TCH002 from singer_sdk.streams import RESTStream +import singer_sdk._singerlib as singer + _Auth = Callable[[requests.PreparedRequest], requests.PreparedRequest] @@ -74,8 +76,9 @@ def get_starting_time(self, context): rep_key = None if start_date: start_date = parser.parse(self.config.get("start_date")) - if context: - rep_key = self.get_starting_timestamp(context) + timedelta(seconds=1) + rep_key = self.get_starting_timestamp(context) + if rep_key: + rep_key = rep_key + timedelta(seconds=1) return rep_key or start_date def get_url_params( @@ -137,3 +140,14 @@ def backoff_max_tries(self) -> int: Number of max retries. """ return 8 + + def _write_state_message(self) -> None: + """Write out a STATE message with the latest state.""" + tap_state = self.tap_state + + if tap_state and tap_state.get("bookmarks"): + for stream_name in tap_state.get("bookmarks").keys(): + if tap_state["bookmarks"][stream_name].get("partitions") and stream_name in ["transaction_detail"]: + tap_state["bookmarks"][stream_name] = {"partitions": []} + + singer.write_message(singer.StateMessage(value=tap_state)) \ No newline at end of file