Skip to content

feat(usage): Fix history usages #3770

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged

feat(usage): Fix history usages #3770

merged 1 commit into from
Jun 2, 2025

Conversation

ivannovosad
Copy link
Contributor

Context

The service calculating historical daily usages used to jump to the next period in case of calculating usages for the last day of current period.

Description

  • Fix the incorrect day of usages in FillHistoryService
  • Fix incorrect boundaries in FillFromInvoiceService

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issues with incorrect daily usage calculations by adjusting the boundaries in two services.

  • In FillHistoryService, the time freezing logic is updated to ensure the correct day is captured.
  • In FillFromInvoiceService, the service now uses charge-specific datetime fields to accurately define usage boundaries.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/services/daily_usages/fill_history_service.rb Updates the time freeze logic to better capture the intended usage day
app/services/daily_usages/fill_from_invoice_service.rb Updates boundaries using charges_from_datetime and charges_to_datetime for correct historical usage calculation
Comments suppressed due to low confidence (1)

app/services/daily_usages/fill_history_service.rb:23

  • [nitpick] Consider renaming the variable 'ds' to a more descriptive name (e.g., 'dates_service') to improve readability and maintainability.
ds = Subscriptions::DatesService.new_instance(subscription, date, current_usage: true)

@ivannovosad ivannovosad merged commit 23e2f09 into main Jun 2, 2025
14 checks passed
@ivannovosad ivannovosad deleted the fix-history-usages branch June 2, 2025 12:30
diegocharles pushed a commit that referenced this pull request Jun 2, 2025
## Context

The service calculating historical daily usages used to jump to the next
period in case of calculating usages for the last day of current period.

## Description

- Fix the incorrect day of usages in `FillHistoryService`
- Fix incorrect boundaries in `FillFromInvoiceService`
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