Commit d6ab58e1 authored by allison.browne's avatar allison.browne

Remove usage data cache and add spec

parent e21aff62
......@@ -18,9 +18,6 @@ class GitlabUsagePingWorker
# Splay the request over a minute to avoid thundering herd problems.
sleep(rand(0.0..60.0).round(3))
# Cache to decouple long running work from the http request context
Gitlab::GrafanaEmbedUsageData.write_issue_count
SubmitUsagePingService.new.execute
end
......
......@@ -4,13 +4,7 @@ module Gitlab
class GrafanaEmbedUsageData
class << self
def issue_count
Rails.cache.read(:grafana_embed_issue_count)
end
def write_issue_count
count = get_embed_count
Rails.cache.write(:grafana_embed_issue_count, count)
count
get_embed_count
end
private
......
......@@ -84,7 +84,7 @@ module Gitlab
issues: count(Issue),
issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue),
issues_using_zoom_quick_actions: count(ZoomMeeting.select(:issue_id).distinct),
issues_with_embeded_grafana_charts: Gitlab::GrafanaEmbedUsageData.count_issues,
issues_with_embeded_grafana_charts: ::Gitlab::GrafanaEmbedUsageData.issue_count,
keys: count(Key),
label_lists: count(List.label),
lfs_objects: count(LfsObject),
......
......@@ -5,7 +5,6 @@ require 'spec_helper'
describe Gitlab::GrafanaEmbedUsageData do
describe '#issue_count', :use_clean_rails_memory_store_caching do
subject do
described_class.write_issue_count
described_class.issue_count
end
......
......@@ -53,6 +53,8 @@ describe Gitlab::UsageData do
create(:grafana_integration, project: projects[1], enabled: true)
create(:grafana_integration, project: projects[2], enabled: false)
allow(Gitlab::GrafanaEmbedUsageData).to receive(:issue_count) { 2 }
ProjectFeature.first.update_attribute('repository_access_level', 0)
end
......@@ -152,6 +154,7 @@ describe Gitlab::UsageData do
issues
issues_with_associated_zoom_link
issues_using_zoom_quick_actions
issues_with_embeded_grafana_charts
keys
label_lists
labels
......@@ -211,6 +214,7 @@ describe Gitlab::UsageData do
expect(count_data[:projects_with_error_tracking_enabled]).to eq(1)
expect(count_data[:issues_with_associated_zoom_link]).to eq(2)
expect(count_data[:issues_using_zoom_quick_actions]).to eq(3)
expect(count_data[:issues_with_embeded_grafana_charts]).to eq(2)
expect(count_data[:clusters_enabled]).to eq(4)
expect(count_data[:project_clusters_enabled]).to eq(3)
......
......@@ -8,7 +8,6 @@ describe GitlabUsagePingWorker do
it 'delegates to SubmitUsagePingService' do
allow(subject).to receive(:try_obtain_lease).and_return(true)
expect(Gitlab::GrafanaEmbedUsageData).to receive(:write_issue_count)
expect_any_instance_of(SubmitUsagePingService).to receive(:execute)
subject.perform
......
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