Skip to content

Commit

Permalink
Merge pull request #13 from harrystech/ynaim/add-logging
Browse files Browse the repository at this point in the history
Bug fix: Subclass out of ExportFile abstract class
  • Loading branch information
ynaim94-harrys authored Oct 28, 2022
2 parents a8c5df8 + 453d365 commit 3d17a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 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-gladly"
version = "0.4.0"
version = "0.4.1"
description = "`tap-gladly` is a Singer tap for gladly, built with the Meltano SDK for Singer Taps."
authors = ["harrystech"]
keywords = [
Expand Down
9 changes: 8 additions & 1 deletion tap_gladly/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ class ExportFile(gladlyStream, abc.ABC):
def get_records(self, context: Optional[Dict[Any, Any]]):
"""Get records that exists, ignoring older jobs if max_job_lookback is setup."""
if not context:
logging.warning("Context is empty, nothing to do")
return []
period = pendulum.now().diff(pendulum.parse(context["updatedAt"])).in_days()
if "max_job_lookback" in self.config:
logging.info(
f"Max job lookback is set to {self.config['max_job_lookback']}"
)
if period <= self.config["max_job_lookback"]:
logging.info(
f"{period} <= {self.config['max_job_lookback']}, syncing ..."
)
return super().get_records(context)
else:
logging.warning(
Expand Down Expand Up @@ -80,7 +87,7 @@ def parse_response(self, response: requests.Response) -> Iterable[dict]:
yield from extract_jsonpath(self.records_jsonpath, input=json.loads(line))


class ExportFileConversationItemsAllTypesStream(gladlyStream):
class ExportFileConversationItemsAllTypesStream(ExportFile):
"""Stream with all the conversations and content type."""

name = "conversation_all_types"
Expand Down

0 comments on commit 3d17a34

Please sign in to comment.