Commit 13ec6cc6 authored by Toon Claes's avatar Toon Claes

Merge branch '205578-add-package-count-to-usage-data-28days' into 'master'

Adds rolling package count to usage data

See merge request gitlab-org/gitlab!40452
parents c4e32480 521a0501
---
title: Adds monthly package data to usage ping
merge_request: 40452
author:
type: added
# frozen_string_literal: true
class AddIdCreatedAtIndexToPackages < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_packages_packages_on_id_and_created_at'
def up
add_concurrent_index :packages_packages, [:id, :created_at], name: INDEX_NAME
end
def down
remove_concurrent_index_by_name(:packages_packages, INDEX_NAME)
end
end
eb13fb285ac9af83bbc66397a5352a824575ad4af93178b98fbfc1be2e11ce8b
\ No newline at end of file
......@@ -20463,6 +20463,8 @@ CREATE INDEX index_packages_package_files_on_package_id_and_file_name ON public.
CREATE INDEX index_packages_packages_on_creator_id ON public.packages_packages USING btree (creator_id);
CREATE INDEX index_packages_packages_on_id_and_created_at ON public.packages_packages USING btree (id, created_at);
CREATE INDEX index_packages_packages_on_name_trigram ON public.packages_packages USING gin (name public.gin_trgm_ops);
CREATE INDEX index_packages_packages_on_project_id_and_created_at ON public.packages_packages USING btree (project_id, created_at);
......
......@@ -181,6 +181,7 @@ module Gitlab
successful_deployments: deployment_count(Deployment.success.where(last_28_days_time_period)),
failed_deployments: deployment_count(Deployment.failed.where(last_28_days_time_period)),
# rubocop: enable UsageData/LargeTable:
packages: count(::Packages::Package.where(last_28_days_time_period)),
personal_snippets: count(PersonalSnippet.where(last_28_days_time_period)),
project_snippets: count(ProjectSnippet.where(last_28_days_time_period))
}.tap do |data|
......
......@@ -101,6 +101,7 @@ FactoryBot.define do
create(:package, project: projects[0])
create(:package, project: projects[0])
create(:package, project: projects[1])
create(:package, created_at: 2.months.ago, project: projects[1])
ProjectFeature.first.update_attribute('repository_access_level', 0)
......
......@@ -479,7 +479,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:project_snippets]).to eq(4)
expect(count_data[:projects_with_packages]).to eq(2)
expect(count_data[:packages]).to eq(3)
expect(count_data[:packages]).to eq(4)
end
it 'gathers object store usage correctly' do
......@@ -572,6 +572,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(counts_monthly[:snippets]).to eq(3)
expect(counts_monthly[:personal_snippets]).to eq(1)
expect(counts_monthly[:project_snippets]).to eq(2)
expect(counts_monthly[:packages]).to eq(3)
end
end
......
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