diff --git a/app/controllers/api/v2/accounts/reports_controller.rb b/app/controllers/api/v2/accounts/reports_controller.rb index ddd629048..03a03a97c 100644 --- a/app/controllers/api/v2/accounts/reports_controller.rb +++ b/app/controllers/api/v2/accounts/reports_controller.rb @@ -1,21 +1,25 @@ class Api::V2::Accounts::ReportsController < Api::V1::Accounts::BaseController include Api::V2::Accounts::ReportsHelper include Api::V2::Accounts::HeatmapHelper + include Reports::MetricFilter before_action :check_authorization def index + # Return empty timeseries array for hidden metrics (preserves expected response shape) + return render json: [] if metric_hidden?(params[:metric]) + builder = V2::Reports::Conversations::ReportBuilder.new(Current.account, report_params) data = builder.timeseries render json: data end def summary - render json: build_summary(:summary) + render json: filter_summary_with_previous(build_summary(:summary)) end def bot_summary - render json: build_summary(:bot_summary) + render json: filter_summary_with_previous(build_summary(:bot_summary)) end def agents diff --git a/app/controllers/api/v2/accounts/summary_reports_controller.rb b/app/controllers/api/v2/accounts/summary_reports_controller.rb index 98b3f05d7..99f7adda8 100644 --- a/app/controllers/api/v2/accounts/summary_reports_controller.rb +++ b/app/controllers/api/v2/accounts/summary_reports_controller.rb @@ -1,4 +1,6 @@ class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseController + include Reports::MetricFilter + before_action :check_authorization before_action :prepare_builder_params, only: [:agent, :team, :inbox, :label, :channel] @@ -40,7 +42,7 @@ class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseContr def render_report_with(builder_class) builder = builder_class.new(account: Current.account, params: @builder_params) - render json: builder.build + render json: filter_hidden_metrics_from_array(builder.build) end def permitted_params