Commit ce5562a8 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '210007-optimize-services_usage-counters' into 'master'

Optimize services_usage  counters using batch counting

See merge request gitlab-org/gitlab!26973
parents 9f58e158 94574f4c
---
title: Optimize services usage counters using batch counters
merge_request: 26973
author:
type: performance
......@@ -183,10 +183,8 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def services_usage
service_counts = count(Service.active.where(template: false).where.not(type: 'JiraService').group(:type), fallback: Hash.new(-1), batch: false)
results = Service.available_services_names.each_with_object({}) do |service_name, response|
response["projects_#{service_name}_active".to_sym] = service_counts["#{service_name}_service".camelize] || 0
results = Service.available_services_names.without('jira').each_with_object({}) do |service_name, response|
response["projects_#{service_name}_active".to_sym] = count(Service.active.where(template: false, type: "#{service_name}_service".camelize))
end
# Keep old Slack keys for backward compatibility, https://gitlab.com/gitlab-data/analytics/issues/3241
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment