From 4dcc1374add527deccb90816a9be081f7ba154bd Mon Sep 17 00:00:00 2001 From: Rohit Chatterjee Date: Mon, 27 May 2024 16:48:03 +0530 Subject: [PATCH] state getter and setter for incremental-stream --- .../source-commcare/source_commcare/source.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/airbyte-integrations/connectors/source-commcare/source_commcare/source.py b/airbyte-integrations/connectors/source-commcare/source_commcare/source.py index 5ade905c2618..f82445973c37 100644 --- a/airbyte-integrations/connectors/source-commcare/source_commcare/source.py +++ b/airbyte-integrations/connectors/source-commcare/source_commcare/source.py @@ -98,12 +98,16 @@ class IncrementalStream(CommcareStream, IncrementalMixin): @property def state(self) -> Mapping[str, Any]: - if self._cursor_value: - return {self.cursor_field: self._cursor_value} + return {self.cursor_field: self._cursor_value} @state.setter def state(self, value: Mapping[str, Any]): - self._cursor_value = datetime.strptime(value[self.cursor_field], self.dateformat) + if self.cursor_field in value: + if "Z" in value[self.cursor_field]: + date_format = "%Y-%m-%dT%H:%M:%S.%fZ" + else: + date_format = "%Y-%m-%dT%H:%M:%S.%f" + self._cursor_value = datetime.strptime(value[self.cursor_field], date_format) @property def sync_mode(self): @@ -140,7 +144,6 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp class Case(IncrementalStream): - """ docs: https://www.commcarehq.org/a/[domain]/api/[version]/case/ """