-
Notifications
You must be signed in to change notification settings - Fork 166
Use sp_return_logs for billing reports, not monthly table #6935
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7d39180
Rewrite total-monthly-auths-report to use sp_return_logs
zachmargolis 135d707
Update combined-invoice-supplement report to use sp_return_logs
zachmargolis 9cda538
Update MonthHelper to not subtract one, most contracts don't "overlap"
zachmargolis 6a3b737
Fix a few specs to use the right tables
zachmargolis 70ae9c6
Add manual retry + rollback
zachmargolis fbc1675
Add changelog
zachmargolis 3f12f17
Fix a few spec stragglers
zachmargolis 25d6e2d
Merge remote-tracking branch 'origin/main' into margolis-plain-return…
zachmargolis c5b005e
Undo switch to timestamps, turns out ::date truncation does in fact
zachmargolis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,24 +102,28 @@ | |
|
|
||
| # 1 unique user in month 1 at IAA 2 @ IAL 2 | ||
| create( | ||
| :monthly_sp_auth_count, | ||
| :sp_return_log, | ||
| user_id: user1.id, | ||
| auth_count: 1, | ||
| ial: 2, | ||
| issuer: iaa2_sp.issuer, | ||
| year_month: inside_iaa2.strftime('%Y%m'), | ||
| requested_at: inside_iaa2, | ||
| returned_at: inside_iaa2, | ||
| billable: true, | ||
| ) | ||
|
|
||
| # 2 users, each 2 auths (1 unique) in month 2 at IAA 2 @ IAL 2 | ||
| [user1, user2].each do |user| | ||
| create( | ||
| :monthly_sp_auth_count, | ||
| user_id: user.id, | ||
| auth_count: 2, | ||
| ial: 2, | ||
| issuer: iaa2_sp.issuer, | ||
| year_month: (inside_iaa2 + 1.month).strftime('%Y%m'), | ||
| ) | ||
| 2.times do | ||
| create( | ||
| :sp_return_log, | ||
| user_id: user.id, | ||
| ial: 2, | ||
| issuer: iaa2_sp.issuer, | ||
| requested_at: inside_iaa2 + 1.month, | ||
| returned_at: inside_iaa2 + 1.month, | ||
| billable: true, | ||
| ) | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -188,7 +192,7 @@ | |
| let(:iaa2_key) { "#{gtc1.gtc_number}-#{format('%04d', iaa_order2.order_number)}" } | ||
|
|
||
| let(:iaa1_range) { Date.new(2020, 4, 15)..Date.new(2021, 4, 14) } | ||
| let(:iaa2_range) { Date.new(2021, 4, 14)..Date.new(2022, 4, 13) } | ||
| let(:iaa2_range) { Date.new(2021, 4, 15)..Date.new(2022, 4, 14) } | ||
| it 'counts up costs by issuer + ial, and includes iaa and app_id' do | ||
| results = JSON.parse(report.perform(Time.zone.today), symbolize_names: true) | ||
|
|
||
|
|
@@ -205,14 +209,26 @@ | |
| iaa_start_date: iaa1_range.begin.to_s, | ||
| iaa_end_date: iaa1_range.end.to_s, | ||
| }, | ||
| { | ||
| iaa: iaa2_key, | ||
| ial1_total_auth_count: 0, | ||
| ial2_total_auth_count: 1, | ||
| ial1_unique_users: 0, | ||
| ial2_unique_users: 1, | ||
| ial1_new_unique_users: 0, | ||
| ial2_new_unique_users: 1, | ||
| year_month: inside_iaa2.strftime('%Y%m'), | ||
| iaa_start_date: iaa2_range.begin.to_s, | ||
| iaa_end_date: iaa2_range.end.to_s, | ||
| }, | ||
|
Comment on lines
+212
to
+223
Contributor
Author
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. I think this is correct now that this has another section... I think it may have been grouped inaccurately before |
||
| { | ||
| iaa: iaa2_key, | ||
| ial1_total_auth_count: 0, | ||
| ial2_total_auth_count: 4, | ||
| ial1_unique_users: 0, | ||
| ial2_unique_users: 2, | ||
| ial1_new_unique_users: 0, | ||
| ial2_new_unique_users: 2, | ||
| ial2_new_unique_users: 1, | ||
| year_month: (inside_iaa2 + 1.month).strftime('%Y%m'), | ||
| iaa_start_date: iaa2_range.begin.to_s, | ||
| iaa_end_date: iaa2_range.end.to_s, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
see commit notes (70ae9c6) for a longer comment, but short version is we get these errors occasionally and I figured it was worth a shot seeing if we could quickly retry + recover rather than abort the entire job
Uh oh!
There was an error while loading. Please reload this page.
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.
and in case it's not obvious what it's doing, we have a ruby nested hash/multiset thing object where we add results incrementally and this is creating a copy before streaming the results, and then restoring the copy to the last known good result every time the query fails
we could rewrite this as
begin/rescuesyntax but we'd need add some sleep code and need a retry counter ourself, so this seemed clear enough? the alternative would be: