summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyasonik <syasonik@gitlab.com>2019-08-07 16:08:52 +0300
committersyasonik <syasonik@gitlab.com>2019-08-07 16:08:52 +0300
commitf505205ed7f39d2bc961a1f7a3094f378176fd35 (patch)
treedf30f905212224b1d71b7004a169c1e5f117d967
parent1a227bc6e2bc1bbe6a68aeab8f46b3149462042a (diff)
downloadgitlab-ce-specific-embeds-be.tar.gz
Use appropriate approach for selecting metricsspecific-embeds-be
-rw-r--r--app/services/metrics/dashboard/custom_metric_embed_service.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/services/metrics/dashboard/custom_metric_embed_service.rb b/app/services/metrics/dashboard/custom_metric_embed_service.rb
index 972e07566df..50f070989fc 100644
--- a/app/services/metrics/dashboard/custom_metric_embed_service.rb
+++ b/app/services/metrics/dashboard/custom_metric_embed_service.rb
@@ -76,14 +76,16 @@ module Metrics
# Metrics which match the provided inputs.
# There may be multiple metrics, but they should be
# displayed in a single panel/chart.
- # @return [Array]
+ # @return [ActiveRecord::AssociationRelation<PromtheusMetric>]
+ # rubocop: disable CodeReuse/ActiveRecord
def metrics
- project.prometheus_metrics.select do |metric|
- metric.group == group_key &&
- metric.title == title &&
- metric.y_label == y_label
- end
+ project.prometheus_metrics.where(
+ group: group_key,
+ title: title,
+ y_label: y_label
+ )
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Returns a symbol representing the group that
# the dashboard's group title belongs to.