-
Notifications
You must be signed in to change notification settings - Fork 33
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
TDL-14896: Make batch_size apply to the first page and TDL-14895: Use the pagination__list_subscriber_interval_quantity config value correctly #64
base: master
Are you sure you want to change the base?
Changes from 16 commits
6c25a28
623d248
50689ba
a71197c
3e4c22c
f069f96
1d23a24
e1acd6a
dbeeb6b
054acac
73aeb95
e353b85
1f56470
520b087
58464cc
e38f478
7a9f289
0418198
a947b16
1a7909b
ca2ca09
6bfe2c0
d6ea31b
e278f8c
4cc3fc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,13 @@ | |
LOGGER = singer.get_logger() | ||
|
||
|
||
def _get_response_items(response): | ||
def _get_response_items(response, name): | ||
items = response.results | ||
|
||
if 'count' in response.results: | ||
LOGGER.info('Got {} results.'.format(response.results.get('count'))) | ||
items = response.results.get('items') | ||
|
||
LOGGER.info('Got %s results from %s endpoint.', len(items), name) | ||
return items | ||
|
||
|
||
|
@@ -107,6 +107,8 @@ def request(name, selector, auth_stub, search_filter=None, props=None, batch_siz | |
""" | ||
cursor = selector() | ||
cursor.auth_stub = auth_stub | ||
# set batch size | ||
cursor.options = {"BatchSize": batch_size} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments regarding the changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comment |
||
|
||
if props is not None: | ||
cursor.props = props | ||
|
@@ -142,22 +144,26 @@ def request_from_cursor(name, cursor, batch_size): | |
raise RuntimeError("Request failed with '{}'" | ||
.format(response.message)) | ||
|
||
for item in _get_response_items(response): | ||
for item in _get_response_items(response, name): | ||
yield item | ||
|
||
while response.more_results: | ||
LOGGER.info("Getting more results from '{}' endpoint".format(name)) | ||
|
||
# Override call to getMoreResults to add a batch_size parameter | ||
# response = cursor.getMoreResults() | ||
response = tap_exacttarget__getMoreResults(cursor, batch_size=batch_size) | ||
LOGGER.info("Fetched {} results from '{}' endpoint".format(len(response.results), name)) | ||
if isinstance(cursor, FuelSDK.ET_Campaign): | ||
# use 'getMoreResults' for campaigns as it does not use | ||
# batch_size, rather it uses $page and $pageSize and REST Call | ||
response = cursor.getMoreResults() | ||
else: | ||
# Override call to getMoreResults to add a batch_size parameter | ||
# response = cursor.getMoreResults() | ||
response = tap_exacttarget__getMoreResults(cursor, batch_size=batch_size) | ||
Comment on lines
+156
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of the above changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of the above change is to support pagination in the tap to run the pagination test. |
||
|
||
if not response.status: | ||
raise RuntimeError("Request failed with '{}'" | ||
.format(response.message)) | ||
|
||
for item in _get_response_items(response): | ||
for item in _get_response_items(response, name): | ||
yield item | ||
|
||
LOGGER.info("Done retrieving results from '{}' endpoint".format(name)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ def __init__(self, config, state, auth_stub, catalog): | |
self.state = state.copy() | ||
self.catalog = catalog | ||
self.auth_stub = auth_stub | ||
# initialize batch size | ||
self.batch_size = int(self.config.get('batch_size', 2500)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use self.batch_size here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, here the batch size is initialized. |
||
|
||
@classmethod | ||
def matches_catalog(cls, catalog): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments to the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments