Skip to content

Commit 2954412

Browse files
committed
Make satisfaction ratings incremental by using a start_time query parameter
1 parent e5644e8 commit 2954412

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tap_zendesk/streams.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,22 @@ class SatisfactionRatings(Stream):
304304

305305
def sync(self, state):
306306
bookmark = self.get_bookmark(state)
307-
308-
satisfaction_ratings = self.client.satisfaction_ratings()
307+
bookmark_epoch = int(bookmark.strftime('%s'))
308+
# We substract a second here because the API seems to compare
309+
# start_time with a >, but we typically prefer a >= behavior.
310+
# Also, the start_time query parameter filters based off of
311+
# created_at, but we found during testing that
312+
# satisfaction_ratings are immutable, and any updates actually
313+
# create a new satisfaction rating, so that updated_at always
314+
# equals created_at
315+
satisfaction_ratings = self.client.satisfaction_ratings(start_time=(bookmark_epoch-1))
309316
for satisfaction_rating in satisfaction_ratings:
310317
if utils.strptime_with_tz(satisfaction_rating.updated_at) >= bookmark:
311318
# NB: We don't trust that the records come back ordered by
312319
# updated_at (we've observed out-of-order records),
313320
# so we can't save state until we've seen all records
314321
self.update_bookmark(state, satisfaction_rating.updated_at)
315-
yield (self.stream, satisfaction_rating)
322+
yield (self.stream, satisfaction_rating)
316323

317324
class Groups(Stream):
318325
name = "groups"

0 commit comments

Comments
 (0)