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

Add Billing Page - CostByMonth - summary of topic per invoice month. #696

Merged
merged 10 commits into from
Mar 7, 2024

Conversation

milo-hyben
Copy link
Contributor

@milo-hyben milo-hyben commented Mar 4, 2024

New Billing page to replace the Google spreadsheet with summary of Storage / Compute cost per topic per invoice month.

@milo-hyben milo-hyben marked this pull request as ready for review March 4, 2024 22:24
@milo-hyben
Copy link
Contributor Author

Hey @illusional this is a simple page, as some stage we might want to add maybe sorting and export to csv.

<div>
<LoadingDucks />
<p style={{ textAlign: 'center', marginTop: '5px' }}>
<em>This query takes a while...</em>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit nitpicky, but if this query doesn't take a while, we shouldn't add it (< 10 seconds)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it can take longer, depending how many months you select. I would keep it there.

Comment on lines 168 to 175
if (
start !== undefined &&
start !== '' &&
start !== null &&
end !== undefined &&
end !== '' &&
end !== null
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe define a noValue method, or just use Javascript's falsey values: https://www.freecodecamp.org/news/what-are-falsey-values-in-javascript/#the-six-falsy-values-in-javascript

Suggested change
if (
start !== undefined &&
start !== '' &&
start !== null &&
end !== undefined &&
end !== '' &&
end !== null
) {
if (!!start && !!end) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ide! Boolean(start) && Boolean(end) works like a charm here.

<Input
label="Start"
fluid
type="date"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be invoice months, probably by a select input, and just generate all those since a hardcoded June 2020 (or whenever the start of billing is).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I would need to create a new component as input can be only "date", "month" is not supported.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a select component (dropdown list)?

const [searchParams] = useSearchParams()

const [start, setStart] = React.useState<string>(
searchParams.get('start') ?? getMonthStartDate()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be start of year?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed that to fixed 202201 - > 202301 as per slack chat.

@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 76.50%. Comparing base (bd3447a) to head (dd95e33).
Report is 1 commits behind head on dev.

Files Patch % Lines
models/models/billing.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #696      +/-   ##
==========================================
- Coverage   76.50%   76.50%   -0.01%     
==========================================
  Files         143      143              
  Lines       11502    11504       +2     
==========================================
+ Hits         8800     8801       +1     
- Misses       2702     2703       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

searchParams.get('start') ?? getMonthStartDate()
)
const [end, setEnd] = React.useState<string>(searchParams.get('end') ?? getMonthEndDate())
const [start, setStart] = React.useState<string>(searchParams.get('start') ?? '2022-01-01')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the start / end of the current year? No stress if this was just a testing value

start_date: start,
end_date: end,
start_date: getAdjustedDay(convertInvoiceMonth(start, true), -2),
end_date: getAdjustedDay(convertInvoiceMonth(end, false), 2),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For good measure haha

Suggested change
end_date: getAdjustedDay(convertInvoiceMonth(end, false), 2),
end_date: getAdjustedDay(convertInvoiceMonth(end, false), 3),

].join('-')
}

const getCurrentInvoiceMonth = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some type annotations missing year + next function

Comment on lines 47 to 48
const currentDate = new Date(`${yearString}-${monthString}-01`)
if (currentDate >= dateStart && currentDate <= dateEnd) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are redundant right? The for loops should cover this pretty okay

@milo-hyben milo-hyben merged commit f67695d into dev Mar 7, 2024
5 checks passed
@milo-hyben milo-hyben deleted the billing-cost-by-month branch March 7, 2024 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants