Commit 5ab3372b authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '212398-harden-optimie-jira-usage-data' into 'master'

Harden  jira usage data

See merge request gitlab-org/gitlab!27973
parents c3eff7a6 84f57b1e
---
title: Harden jira usage data
merge_request: 27973
author:
type: performance
......@@ -202,7 +202,7 @@ module Gitlab
results = {
projects_jira_server_active: 0,
projects_jira_cloud_active: 0,
projects_jira_active: -1
projects_jira_active: 0
}
Service.active
......@@ -217,14 +217,12 @@ module Gitlab
results[:projects_jira_server_active] += counts[:server].count if counts[:server]
results[:projects_jira_cloud_active] += counts[:cloud].count if counts[:cloud]
if results[:projects_jira_active] == -1
results[:projects_jira_active] = services.size
else
results[:projects_jira_active] += services.size
end
results[:projects_jira_active] += services.size
end
results
rescue ActiveRecord::StatementInvalid
{ projects_jira_server_active: -1, projects_jira_cloud_active: -1, projects_jira_active: -1 }
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -85,6 +85,13 @@ describe Gitlab::UsageData, :aggregate_failures do
expect { subject }.not_to raise_error
end
it 'jira usage works when queries time out' do
allow_any_instance_of(ActiveRecord::Relation)
.to receive(:find_in_batches).and_raise(ActiveRecord::StatementInvalid.new(''))
expect { described_class.jira_usage }.not_to raise_error
end
end
describe '#usage_data_counters' do
......
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