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

feat(DailyUsage): Add daily_usages:fill_history task #2751

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

vincent-pochet
Copy link
Collaborator

@vincent-pochet vincent-pochet commented Oct 29, 2024

Context

This PR is part of the Usage Revenue and unit.

Today, Lago does not offer a way to retrieve customer usage with a granularity lower than the billing period (via invoices and fees). On the other end, it is possible to get the current usage for a customer/subscription, but this usage is just a “snapshot” of the usage a the current time.

Description

This PR adds a rake task to fill the daily usage history for a specific organization

@vincent-pochet vincent-pochet force-pushed the feat-daily-usage-history branch 5 times, most recently from c3534c9 to c420967 Compare November 5, 2024 10:30
@vincent-pochet vincent-pochet force-pushed the feat-daily-usage-history branch 2 times, most recently from cedfd47 to b354e6d Compare November 5, 2024 14:53
@vincent-pochet vincent-pochet force-pushed the feat-daily-usage-history branch from b354e6d to 5f8636e Compare November 5, 2024 15:05
@vincent-pochet vincent-pochet marked this pull request as ready for review November 5, 2024 15:14
@vincent-pochet vincent-pochet changed the title feat(DailyUsage): Add daily_usages:fill_daily_usage task feat(DailyUsage): Add daily_usages:fill_history task Nov 5, 2024
@vincent-pochet vincent-pochet merged commit 8da36e9 into main Nov 8, 2024
6 checks passed
@vincent-pochet vincent-pochet deleted the feat-daily-usage-history branch November 8, 2024 10:02
vincent-pochet added a commit that referenced this pull request Nov 21, 2024
…rvice (#2843)

## Context

A rake task to fill the history data of the DailyUsage model was
recently added (#2751)

Since this task is recomputing the usage for all subscriptions of an
organization for a defined number of days, without taking advantage of
the usage cache, it can be very slow. Also, an organization can have a
large number of subscription, making the current linear approach very
inefficient.

## Description

This PR extracts the existing logic from the rake task itself in a
job/service, taking advantage of sidekiq to parralelize the work
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.

2 participants