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(persisted-metrics): Add new type of aggregation #415

Merged
merged 1 commit into from
Sep 1, 2022
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
1 change: 1 addition & 0 deletions app/models/billable_metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BillableMetric < ApplicationRecord
sum_agg
max_agg
unique_count_agg
recurring_count_agg
].freeze

enum billable_period: BILLABLE_PERIODS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module BillableMetrics
module Aggregations
class RecurringCountService < BillableMetrics::Aggregations::BaseService
def aggregate(from_date:, to_date:, options: {})
# TODO: implement aggregation logic
result.aggregation = 0
result.count = 0
result
end
end
end
end
2 changes: 2 additions & 0 deletions app/services/fees/charge_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def aggregator
BillableMetrics::Aggregations::SumService
when :unique_count_agg
BillableMetrics::Aggregations::UniqueCountService
when :recurring_count_agg
BillableMetrics::Aggregations::RecurringCountService
else
raise NotImplementedError
end
Expand Down
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ input AddStripePaymentProviderInput {
enum AggregationTypeEnum {
count_agg
max_agg
recurring_count_agg
sum_agg
unique_count_agg
}
Expand Down
6 changes: 6 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "recurring_count_agg",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
]
},
Expand Down