-
Notifications
You must be signed in to change notification settings - Fork 47
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 20674 Reduce API calls to stripe v2.0.0 #150
Conversation
tap_stripe/__init__.py
Outdated
event_window_size = 30 | ||
LOGGER.warning("Using event window size of 30 days for %s stream.", stream_name) | ||
events_date_window_size = int(60 * 60 * 24 * event_window_size) # event_window_size in seconds | ||
sync_start_time = dt_to_epoch(utils.now()) - events_date_window_size |
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.
sync_start_time = dt_to_epoch(utils.now()) - events_date_window_size | |
sync_start_time = dt_to_epoch(utils.now()) |
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.
Removed events_date_window_size
and moved it at bottom part of function for better readability.
tap_stripe/__init__.py
Outdated
# Write bookmark for parent or child stream if it is selected | ||
write_bookmark_for_event_updates(is_sub_stream, stream_name, sub_stream_name, max_created) | ||
|
||
max_created = max(max_created, sync_start_time) |
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.
max_created = max(max_created, sync_start_time) | |
max_created = max(max_created, sync_start_time-events_date_window_size) |
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.
Updated logic to write the final bookmark value.
tap_stripe/__init__.py
Outdated
date_window_start = max_created | ||
date_window_end = max_created + date_window_size | ||
# Start sync from 30 days before if bookmark/start_date is older than 30 days. | ||
max_created = int(max(bookmark_value, (singer.utils.now() - timedelta(days=30)).timestamp())) |
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.
max_created = int(max(bookmark_value, (singer.utils.now() - timedelta(days=30)).timestamp())) | |
max_created = int(max(bookmark_value, (sync_start_time - timedelta(days=30)).timestamp())) |
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.
Replaced singer.utils.now()
with sync_start_time
to remove minor diff of the time.
tap_stripe/__init__.py
Outdated
# Write bookmark for parent or child stream if it is selected | ||
write_bookmark_for_event_updates(is_sub_stream, stream_name, sub_stream_name, max_created) | ||
|
||
max_created = max(max_created, sync_start_time - events_date_window_size) |
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.
Add code comment and reason behind this change.
…b.com/singer-io/tap-stripe into TDL-20557-reduced-api-calls-to-stripe
tap_stripe/__init__.py
Outdated
@@ -451,7 +452,12 @@ def reduce_foreign_keys(rec, stream_name): | |||
rec['lines'][k] = [li.to_dict_recursive() for li in val] | |||
return rec | |||
|
|||
|
|||
# Retry 429 RateLimitError 5 times. |
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.
6 times.
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.
We have updated retry count to 7. Hence, updated message according to this.
# Write the parent bookmark value only when the parent is selected | ||
if not is_sub_stream: | ||
singer.write_bookmark(Context.state, | ||
stream_name + '_events', |
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.
We are already writing state in write_bookmark_for_event_updates()
so we can remove this statement.
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.
Removed write_state
statements.
max_created) | ||
singer.write_state(Context.state) | ||
|
||
|
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.
Remove this statement and put at the last line of this method.
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.
Moved write_state
to common place.
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.
Requested changes inline.
…b.com/singer-io/tap-stripe into TDL-20557-reduced-api-calls-to-stripe
As CircleCi is down, the following test scenarios are tested locally on dev-vm - Unit tests -
Integration Tests -
|
Description of change
event_date_date_window
.event_date_date_window
is 7 days and maximum possible value of it is 30 days.event_updates
for last 30 days only. Ifstart_date
orlast saved bookmark
value is before 30 days, then start the sync from the last 30 days only.sync_start_time - event_date_window
as bookmark forevent_updates
.Manual QA steps
Risks
Rollback steps