-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] List cost centers with expired billing time #14229
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
Conversation
Where("billingStrategy = ?", strategy). | ||
Group("id"). | ||
Where("nextBillingTime != ?", ""). | ||
Where("nextBillingTime < ?", TimeToISO8601(billingTimeBefore)) |
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.
All conditions need to be applied to the main query, otherwise we wouldn't necessarily get the latest cost center per attributionid.
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 do the join ON (id, creationTime)
so we should get only the most recent one, due to the MAX(createdTime)
. The unit test in this PR also looks to work.
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.
I think the subselect doesn't fetch the latest version of each cost center, but the latest one fulfilling the conditions. So if say I change to stripe
it would pick the outdated version where my cost center was other
. Likewise if you test with firstCreation.Add(12 * time.Hour)
, that is a point between first and second, your query would return the outdated costcenter.
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.
Will add a test for this.
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.
Thanks for flagging, you indeed spotted this correctly. I've now added a test to validate this as well.
/hold for adding a test and adjusting Query |
2cebdd6
to
4578dae
Compare
4578dae
to
c4795b3
Compare
Query adjusted and unit test added |
Description
Related Issue(s)
How to test
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide