-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[usage] Round workspace runtime #10591
Conversation
I personally think that rounding at this layer is losing precision for no good reason. The rounding can always happen before it's inserted into the DB, or before it's synced into stripe but the report should remain as accurate as possible. It is an intermediate representation. |
@@ -131,7 +131,7 @@ func (u *UsageReconciler) ReconcileTimeRange(ctx context.Context, from, to time. | |||
func generateUsageReport(teams []teamWithWorkspaces, maxStopTime time.Time) ([]TeamUsage, error) { | |||
var report []TeamUsage | |||
for _, team := range teams { | |||
var teamTotalRuntime float64 | |||
var teamTotalRuntime int64 |
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.
Thought: This could even be uint64
right? (I don't think we want to support "negative usage time", so we can double our max representable value 🙌)
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.
If this really is only about "usage"/"runtime", I agree. If we want to represent "credits" here (which I'm not sure we want/should..?) then int64 it is.
Another thought: Not sure how (type) safe uint64
/int64
interactions are in Go: Is it easy to mess it up? If yes, that might be a good argument too keep one type everywhere (most likely in64
if we need the "positive" side)
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 again!
I personally think that rounding at this layer is losing precision for no good reason. The rounding can always happen before it's inserted into the DB, or before it's synced into stripe but the report should remain as accurate as possible. It is an intermediate representation.
Thanks for voicing these concerns. I do understand your point, however I still believe that the extra readability and sanity of integer values for seconds outweighs any benefits given by sub-second precision. Still, if we really do want sub-second precision one day, I think it will be easy to adjust. 😊
Approving, but holding due to one optional suggestion.
/hold
My 2 cents:
|
Since Milan is on holidays, let's merge this as is and address the review comments in follow-up PRs. /unhold |
Description
As requested in #10583 (review).
Related Issue(s)
Fixes #
How to test
Unit tests
Release Notes
Documentation
NONE