Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use start_time for satisfaction_ratings stream #37

Merged
merged 2 commits into from
Mar 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tap_zendesk/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,21 @@ class SatisfactionRatings(Stream):

def sync(self, state):
bookmark = self.get_bookmark(state)

satisfaction_ratings = self.client.satisfaction_ratings()
bookmark_epoch = int(bookmark.strftime('%s'))
# We substract a second here because the API seems to compare
# start_time with a >, but we typically prefer a >= behavior.
# Also, the start_time query parameter filters based off of
# created_at, but zendesk support confirmed with us that
# satisfaction_ratings are immutable so that created_at =
# updated_at
satisfaction_ratings = self.client.satisfaction_ratings(start_time=(bookmark_epoch-1))
for satisfaction_rating in satisfaction_ratings:
if utils.strptime_with_tz(satisfaction_rating.updated_at) >= bookmark:
# NB: We don't trust that the records come back ordered by
# updated_at (we've observed out-of-order records),
# so we can't save state until we've seen all records
self.update_bookmark(state, satisfaction_rating.updated_at)
yield (self.stream, satisfaction_rating)
yield (self.stream, satisfaction_rating)

class Groups(Stream):
name = "groups"
Expand Down