diff --git a/app/models/billable_metric.rb b/app/models/billable_metric.rb index 2bce2934b41..3412215190d 100644 --- a/app/models/billable_metric.rb +++ b/app/models/billable_metric.rb @@ -16,6 +16,7 @@ class BillableMetric < ApplicationRecord sum_agg max_agg unique_count_agg + recurring_count_agg ].freeze enum billable_period: BILLABLE_PERIODS diff --git a/app/services/billable_metrics/aggregations/recurring_count_service.rb b/app/services/billable_metrics/aggregations/recurring_count_service.rb new file mode 100644 index 00000000000..b38e4c870b6 --- /dev/null +++ b/app/services/billable_metrics/aggregations/recurring_count_service.rb @@ -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 diff --git a/app/services/fees/charge_service.rb b/app/services/fees/charge_service.rb index 343646bf854..a0e1dbd8672 100644 --- a/app/services/fees/charge_service.rb +++ b/app/services/fees/charge_service.rb @@ -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 diff --git a/schema.graphql b/schema.graphql index ee6a82b4ffc..376a230e09a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -62,6 +62,7 @@ input AddStripePaymentProviderInput { enum AggregationTypeEnum { count_agg max_agg + recurring_count_agg sum_agg unique_count_agg } diff --git a/schema.json b/schema.json index 179742602fc..570e2a427fe 100644 --- a/schema.json +++ b/schema.json @@ -551,6 +551,12 @@ "description": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "recurring_count_agg", + "description": null, + "isDeprecated": false, + "deprecationReason": null } ] },