-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] Allow selecting billed months #11617
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
191deb7
to
6381a0b
Compare
a6d0586
to
17e7d34
Compare
058f78a
to
2517be8
Compare
b584718
to
2b56493
Compare
</defs> | ||
</svg> | ||
<span>{calculateTotalUsage()} Total Credits</span> | ||
<CreditsSvg className="my-auto mr-1" /> |
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.
This is a drive-by improvement to extract the SVGs.
2b56493
to
7264a65
Compare
for (let i = 1; i < 7; i++) { | ||
const endDateVar = i - 1; | ||
const startDate = new Date(today.getFullYear(), today.getMonth() - i); | ||
const endDate = new Date(today.getFullYear(), today.getMonth() - endDateVar, 0); |
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.
Using this might make it easier logic vise. https://stackoverflow.com/questions/41505492/how-to-subtract-one-month-using-moment-js
I suspect the current logic has a bug for when 7 months back goes back to the previous year, as then you need to wrap the month and subtract 1 year
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.
You can test it by changing it to generate 12 months, or even 24 to see it
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 suspect the current logic has a bug for when 7 months back goes back to the previous year, as then you need to wrap the month and subtract 1 year
It actually computes it as expected! I tried going back 12 months from July 2022 and it correctly shows me as July 2021.
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'm surprised! But the JS version of Date, which is based on Java 1.0 package actually allows you to subtract from dates by using negative months!
var now = new Date()
now
Wed Jul 27 2022 11:02:40 GMT+0200 (Central European Summer Time)
new Date(now.getFullYear(), now.getMonth() - 10, 0)
Tue Aug 31 2021 00:00:00 GMT+0200 (Central European Summer 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.
LGTM
/hold
In case you want someone else to review.
7264a65
to
422ab8b
Compare
Thanks! The functionality works but the list of months is much uglier than the dropdown. Since there are a bunch of other things that needs to be fixed, I'll unhold and move on to not block subsequent work, but I'm aware that we'll need to implement the dropdown or at least improve how it looks. |
Description
Allows users to select billing months.
Related Issue(s)
Fixes #11526
How to test
Go to https://lau-time-view-11526.preview.gitpod-dev.com/t/gitpod/usage and click on the previous months.
Release Notes
Documentation
Werft options: