Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions nise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .helpers import gcp_calculate_persistent_disk_usage_amount
from .helpers import gcp_calculate_usage_amount_in_pricing

__version__ = "5.4.1"
VERSION = __version__.split(".")
__version__ = "5.4.2"
16 changes: 13 additions & 3 deletions nise/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ def _load_static_report_data(options):
start_date = get_start_date(attributes, options)
generated_start_date = calculate_start_date(start_date)
start_dates.append(generated_start_date)

end_date = attributes.get("end_date", options.get("end_date"))
generated_end_date = today()
if end_date and (
Expand All @@ -680,12 +679,23 @@ def _load_static_report_data(options):
options["start_date"] = min(start_dates)
latest_date = max(end_dates)
last_day_of_month = calendar.monthrange(year=latest_date.year, month=latest_date.month)[1]
options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0)

# Allow partial data generation on the last day of the month (e.g., 8 a.m. - 2 p.m.).
# Otherwise, the start date could be > the month's end date, which would skip data generation
# (options["end_date"] is later used to set the month's end date).
if (
options.get("end_date")
and isinstance(options["end_date"], datetime.datetime)
and options["end_date"].date() == datetime.date(latest_date.year, latest_date.month, last_day_of_month)
):
options["end_date"] = options["end_date"].replace(tzinfo=datetime.UTC)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition relies on options.get("end_date") being a datetime.datetime, but in some scenarios (last day of the month) with no --end-date it will be None, so the if is never entered.

Does that make sense?

else:
options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0)
Comment thread
esebesto marked this conversation as resolved.
Comment thread
esebesto marked this conversation as resolved.

options["static_report_data"] = static_report_data

if options.get("provider") == "aws" and aws_tags:
options["aws_tags"] = aws_tags

return True


Expand Down
Loading