diff --git a/lib/sanbase/metric/helper.ex b/lib/sanbase/metric/helper.ex index e37b74ad3..e11289809 100644 --- a/lib/sanbase/metric/helper.ex +++ b/lib/sanbase/metric/helper.ex @@ -156,7 +156,7 @@ defmodule Sanbase.Metric.Helper do # If there is a metric that has a different set of aggregations compared to # the other metrics in the module, this needs to be reworked to call # module.metadata(metric) - Map.put_new(acc, metric, [nil] ++ module.available_aggregations()) + Map.put(acc, metric, [nil] ++ module.available_aggregations()) end end @@ -199,7 +199,7 @@ defmodule Sanbase.Metric.Helper do metric <- module.available_metrics(), reduce: %{} do acc -> - Map.put_new(acc, metric, module) + Map.put(acc, metric, module) end end @@ -218,7 +218,7 @@ defmodule Sanbase.Metric.Helper do metric <- module.available_timeseries_metrics(), reduce: %{} do acc -> - Map.put_new(acc, metric, module) + Map.put(acc, metric, module) end end @@ -237,7 +237,7 @@ defmodule Sanbase.Metric.Helper do metric <- module.available_histogram_metrics(), reduce: %{} do acc -> - Map.put_new(acc, metric, module) + Map.put(acc, metric, module) end end @@ -256,7 +256,7 @@ defmodule Sanbase.Metric.Helper do metric <- module.available_table_metrics(), reduce: %{} do acc -> - Map.put_new(acc, metric, module) + Map.put(acc, metric, module) end end diff --git a/lib/sanbase/social_data/metric_adapter.ex b/lib/sanbase/social_data/metric_adapter.ex index 5e5f28479..226ba99de 100644 --- a/lib/sanbase/social_data/metric_adapter.ex +++ b/lib/sanbase/social_data/metric_adapter.ex @@ -13,7 +13,7 @@ defmodule Sanbase.SocialData.MetricAdapter do alias Sanbase.SocialData.SocialHelper alias Sanbase.Project - @aggregations [:sum] + @aggregations [:sum, :avg] @sources ["total"] ++ SocialHelper.sources() @social_volume_timeseries_metrics ["nft_social_volume"] ++ Enum.map(@sources, fn source -> @@ -323,13 +323,20 @@ defmodule Sanbase.SocialData.MetricAdapter do _ -> "5m" end + default_aggregation = + cond do + String.contains?(metric, "social_dominance") -> :avg + String.contains?(metric, "volume_consumed") -> :avg + true -> :sum + end + {:ok, %{ metric: metric, internal_metric: metric, has_incomplete_data: has_incomplete_data?(metric), min_interval: min_interval, - default_aggregation: :sum, + default_aggregation: default_aggregation, available_aggregations: @aggregations, available_selectors: selectors, required_selectors: [],