Skip to content

Commit

Permalink
chore: changes from review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
a-rampalli committed Jul 20, 2023
1 parent a1a4751 commit 440362a
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ def request_params(self, next_page_token: Mapping[str, Any] = None, **kwargs) ->

class SourceZendeskSupportOffsetPaginationStream(SourceZendeskSupportFullRefreshStream):
"""
Functionality of this class copied into a SourceZendeskSupportPaginationStream class and modified to suit rudderstack needs.
This class is being retained to not break existing incremental streams using this class.
TODO: Migrate incremental streams to SourceZendeskSupportPaginationStream also and remove this class.
TODO: Migrate incremental streams to SourceZendeskSupportPaginationStream also and see if we can remove this class.
"""

cursor_field = "updated_at"
Expand All @@ -441,7 +439,7 @@ def state_checkpoint_interval(self) -> Optional[int]:
"""
Will allow the connector send state messages more frequent and not only at the end of the sync.
"""
return 1000
return self.page_size

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]:
# try to save maximum value of a cursor field
Expand Down Expand Up @@ -479,9 +477,6 @@ def request_params(
class SourceZendeskSupportCursorPaginationStream(SourceZendeskSupportFullRefreshStream):
"""
Only used by streams modified by rudderstack
Implements cursor pagination as most streams support cursor pagination.
Where it is not supported such streams will override some of this functionality to
use offset pagination.
"""

cursor_field = "updated_at"
Expand All @@ -493,7 +488,7 @@ def state_checkpoint_interval(self) -> Optional[int]:
"""
Will allow the connector send state messages more frequent and not only at the end of the sync.
"""
return 1000
return self.page_size

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]:
# try to save maximum value of a cursor field
Expand Down Expand Up @@ -527,6 +522,7 @@ def request_params(
https://developer.zendesk.com/documentation/api-basics/pagination/paginating-through-lists-using-cursor-pagination/#enabling-cursor-pagination
"""
params = {
# Latest value of state is used as start_time for making api call at the beginning of every sync run where we don't have a next-page token
"start_time": parsed_state,
"page[size]": self.page_size,
"sort_by": self.cursor_field,
Expand Down Expand Up @@ -688,10 +684,11 @@ class TicketFields(SourceZendeskSupportStream):
"""TicketFields stream: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/"""


class TicketForms(SourceZendeskSupportCursorPaginationStream):
class TicketForms(SourceZendeskSupportOffsetPaginationStream):
"""TicketForms stream: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms"""

# Does not support cursor based pagination so using offset based pagination
# next_page field from API response has page number instead of start_time being expected in parent class
# hence we need to override below methods
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
if self._ignore_pagination:
return None
Expand Down Expand Up @@ -769,7 +766,6 @@ def request_params(
params = {
"start_time": parsed_state,
"page[size]": self.page_size,
"sort_order": "asc",
}
if next_page_token:
params.update(next_page_token)
Expand Down

0 comments on commit 440362a

Please sign in to comment.