Skip to content
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] Allow selecting billed months #11617

Merged
merged 1 commit into from
Jul 27, 2022
Merged

[usage] Allow selecting billed months #11617

merged 1 commit into from
Jul 27, 2022

Conversation

laushinka
Copy link
Contributor

@laushinka laushinka commented Jul 25, 2022

Description

Allows users to select billing months.

Screenshot 2022-07-27 at 10 43 37

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

NONE

Documentation

Werft options:

  • /werft with-preview

</defs>
</svg>
<span>{calculateTotalUsage()} Total Credits</span>
<CreditsSvg className="my-auto mr-1" />
Copy link
Contributor Author

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.

@laushinka laushinka marked this pull request as ready for review July 27, 2022 08:43
@laushinka laushinka requested a review from a team July 27, 2022 08:43
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Jul 27, 2022
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);
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Member

@easyCZ easyCZ left a 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.

@laushinka
Copy link
Contributor Author

laushinka commented Jul 27, 2022

LGTM

/hold In case you want someone else to review.

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.
Again, really sorry @gtsiolis 🙏🏽

@roboquat roboquat merged commit 9e2ccb5 into main Jul 27, 2022
@roboquat roboquat deleted the lau/time-view-11526 branch July 27, 2022 09:18
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to switch between months and update usage page sidebar designs
3 participants