From 7c795f489257df50f020b5b7e8039a0bc74145cb Mon Sep 17 00:00:00 2001 From: Vincent Pochet Date: Thu, 24 Oct 2024 14:18:13 +0200 Subject: [PATCH] feat(felixible aggregation): Expose expression in API --- lib/lago/api/resources/billable_metric.rb | 1 + spec/fixtures/api/billable_metric.json | 7 ++----- spec/fixtures/api/billable_metric_index.json | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/lago/api/resources/billable_metric.rb b/lib/lago/api/resources/billable_metric.rb index d17dd50..b2b69e8 100644 --- a/lib/lago/api/resources/billable_metric.rb +++ b/lib/lago/api/resources/billable_metric.rb @@ -22,6 +22,7 @@ def whitelist_params(params) aggregation_type: params[:aggregation_type], weighted_interval: params[:weighted_interval], field_name: params[:field_name], + expression: params[:expression], filters: params[:filters], }.compact, } diff --git a/spec/fixtures/api/billable_metric.json b/spec/fixtures/api/billable_metric.json index f951bd4..a7ab7c4 100644 --- a/spec/fixtures/api/billable_metric.json +++ b/spec/fixtures/api/billable_metric.json @@ -7,16 +7,13 @@ "aggregation_type": "sum_agg", "weighted_interval": null, "recurring": false, + "expression": "1 + 2", "field_name": "amount_sum", "created_at": "2022-04-29T08:59:51Z", "filters": [ { "key": "country", - "values": [ - "france", - "italy", - "spain" - ] + "values": ["france", "italy", "spain"] } ], "active_subscriptions_count": 0, diff --git a/spec/fixtures/api/billable_metric_index.json b/spec/fixtures/api/billable_metric_index.json index 4fc85f9..d17df3b 100644 --- a/spec/fixtures/api/billable_metric_index.json +++ b/spec/fixtures/api/billable_metric_index.json @@ -8,6 +8,7 @@ "aggregation_type": "sum_agg", "weighted_interval": null, "recurring": false, + "expression": "1 + 2", "field_name": "amount_sum", "created_at": "2022-04-29T08:59:51Z", "filters": [], @@ -23,6 +24,7 @@ "aggregation_type": "sum_agg", "weighted_interval": null, "recurring": false, + "expression": "1 + 2", "field_name": "amount_sum", "created_at": "2022-04-30T08:59:51Z", "filters": [],