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

misc: small refactoring regarding caching and event stores #1691

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
12 changes: 12 additions & 0 deletions app/services/events/stores/base_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,25 @@ def prorated_sum(period_duration:, persisted_duration: nil)
raise NotImplementedError
end

def grouped_prorated_sum(period_duration:, persisted_duration: nil)
raise NotImplementedError
end

# NOTE: returns the breakdown of the sum grouped by date
# The result format will be an array of hash with the format:
# [{ date: Date.parse('2023-11-27'), value: 12.9 }, ...]
def sum_date_breakdown
raise NotImplementedError
end

def weighted_sum(initial_value: 0)
raise NotImplementedError
end

def grouped_weighted_sum(initial_values: [])
raise NotImplementedError
end

def from_datetime
boundaries[:from_datetime]
end
Expand Down
7 changes: 1 addition & 6 deletions app/services/invoices/customer_usage_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ def compute_amounts
end

def charge_cache_key(charge)
[
'charge-usage',
charge.id,
subscription.id,
charge.updated_at.iso8601,
].join('/')
Subscriptions::ChargeCacheService.new(subscription:, charge:).cache_key
end

def charge_cache_expiration
Expand Down
Loading