Commit 7475402e authored by Sean Arnold's avatar Sean Arnold Committed by Adam Hegyi

Add index for project_id on incident issue type

- Update schema
parent c60be175
---
title: Add projects_creating_incidents to usage ping counts
merge_request: 42934
author:
type: added
# frozen_string_literal: true
class AddIncidentIssueTypeIndexToIssues < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INCIDENT_ISSUE_TYPE = 1
INDEX_NAME = 'index_issues_project_id_issue_type_incident'
def up
add_concurrent_index :issues, :project_id, where: "issue_type = #{INCIDENT_ISSUE_TYPE}", name: INDEX_NAME
end
def down
remove_concurrent_index_by_name(:issues, INDEX_NAME)
end
end
8e0c5be3d6fe2d0d718c7b7a99d84b14dfc6006f780ec0622eb5aae937e6b367
\ No newline at end of file
...@@ -20372,6 +20372,8 @@ CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at); ...@@ -20372,6 +20372,8 @@ CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at);
CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL); CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
CREATE INDEX index_issues_project_id_issue_type_incident ON issues USING btree (project_id) WHERE (issue_type = 1);
CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON jira_connect_installations USING btree (client_key); CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON jira_connect_installations USING btree (client_key);
CREATE INDEX index_jira_connect_subscriptions_on_namespace_id ON jira_connect_subscriptions USING btree (namespace_id); CREATE INDEX index_jira_connect_subscriptions_on_namespace_id ON jira_connect_subscriptions USING btree (namespace_id);
......
...@@ -138,6 +138,7 @@ module Gitlab ...@@ -138,6 +138,7 @@ module Gitlab
pages_domains: count(PagesDomain), pages_domains: count(PagesDomain),
pool_repositories: count(PoolRepository), pool_repositories: count(PoolRepository),
projects: count(Project), projects: count(Project),
projects_creating_incidents: distinct_count(Issue.incident, :project_id),
projects_imported_from_github: count(Project.where(import_type: 'github')), projects_imported_from_github: count(Project.where(import_type: 'github')),
projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)), projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),
projects_with_error_tracking_enabled: count(::ErrorTracking::ProjectErrorTrackingSetting.where(enabled: true)), projects_with_error_tracking_enabled: count(::ErrorTracking::ProjectErrorTrackingSetting.where(enabled: true)),
......
...@@ -497,6 +497,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -497,6 +497,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:personal_snippets]).to eq(2) expect(count_data[:personal_snippets]).to eq(2)
expect(count_data[:project_snippets]).to eq(4) expect(count_data[:project_snippets]).to eq(4)
expect(count_data[:projects_creating_incidents]).to eq(2)
expect(count_data[:projects_with_packages]).to eq(2) expect(count_data[:projects_with_packages]).to eq(2)
expect(count_data[:packages]).to eq(4) expect(count_data[:packages]).to eq(4)
expect(count_data[:user_preferences_user_gitpod_enabled]).to eq(1) expect(count_data[:user_preferences_user_gitpod_enabled]).to eq(1)
......
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