Skip to content

Conversation

rsempe
Copy link
Collaborator

@rsempe rsempe commented Jul 28, 2025

The goal of this PR is to improve performance when doing the backfill of daily usages by avoiding creating fees with 0 units on customer usage for charge filters.

Here is an example for a single subscription linked to 24 billable metrics with 2 filters.
Only 37 daily usages have been created.

Before:

Benchmark.bm do |x|
  x.report("FillHistoryService:") do
    DailyUsages::FillHistoryService.call!(subscription: s, from_datetime: DateTime.new(2025, 5, 1))
  end
end

user     system      total        real
FillHistoryService: 31.097790   1.076836  32.174626 ( 64.291435)

Took 64.29s

After:

Benchmark.bm do |x|
  x.report("FillHistoryService:") do
    DailyUsages::FillHistoryService.call!(subscription: s, from_datetime: DateTime.new(2025, 5, 1))
  end
end

user     system      total        real
FillHistoryService: 20.107554   0.743215  20.850769 ( 41.683220)

Took 41.68s

@rsempe rsempe force-pushed the usage branch 7 times, most recently from 87752dc to e61010f Compare July 31, 2025 09:49
@rsempe rsempe marked this pull request as ready for review August 8, 2025 15:51
@rsempe rsempe merged commit e0d2049 into main Aug 11, 2025
14 checks passed
@rsempe rsempe deleted the usage branch August 11, 2025 06:07
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