Commit 501fb0fb authored by Douwe Maan's avatar Douwe Maan

Merge branch '5581-usage-ping-external-ci-cd-repositories' into 'master'

Usage ping for projects_mirrored_with_pipelines_enabled

See merge request gitlab-org/gitlab-ee!5373
parents fe4b55d9 52d31e55
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180405142733) do
ActiveRecord::Schema.define(version: 20180419031622) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -2051,6 +2051,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do
add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree
add_index "projects", ["description"], name: "index_projects_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"}
add_index "projects", ["id"], name: "index_projects_on_id_partial_for_visibility", unique: true, where: "(visibility_level = ANY (ARRAY[10, 20]))", using: :btree
add_index "projects", ["id"], name: "index_projects_on_mirror_and_mirror_trigger_builds_both_true", where: "((mirror IS TRUE) AND (mirror_trigger_builds IS TRUE))", using: :btree
add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree
add_index "projects", ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed", using: :btree
add_index "projects", ["last_repository_updated_at"], name: "index_projects_on_last_repository_updated_at", using: :btree
......
class AddIndexForTrackingMirroredCiCdRepositories < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
INDEX_NAME = :index_projects_on_mirror_and_mirror_trigger_builds_both_true
def up
return unless Gitlab::Database.postgresql?
if_not_exists = Gitlab::Database.version.to_f >= 9.5 ? "IF NOT EXISTS" : ""
execute("CREATE INDEX CONCURRENTLY #{if_not_exists} #{INDEX_NAME} ON projects (id) WHERE (mirror IS TRUE AND mirror_trigger_builds IS TRUE);")
end
def down
return unless Gitlab::Database.postgresql?
execute("DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};")
end
end
......@@ -92,6 +92,7 @@ module Gitlab
projects: Project.count,
projects_imported_from_github: Project.where(import_type: 'github').count,
projects_reporting_ci_cd_back_to_github: GithubService.without_defaults.active.count,
projects_mirrored_with_pipelines_enabled: projects_mirrored_with_pipelines_enabled,
protected_branches: ProtectedBranch.count,
releases: Release.count,
remote_mirrors: RemoteMirror.count,
......@@ -178,6 +179,16 @@ module Gitlab
results = Service.unscoped.where(type: types.keys, active: true).group(:type).count
results.each_with_object({}) { |(key, value), response| response[types[key.to_sym]] = value }
end
def projects_mirrored_with_pipelines_enabled
Project.joins(:project_feature).where(
mirror: true,
mirror_trigger_builds: true,
project_features: {
builds_access_level: ProjectFeature::ENABLED
}
).count
end
end
end
end
......@@ -70,6 +70,7 @@ describe Gitlab::UsageData do
expect(count_data.keys).to match_array(%i(
boards
ci_builds
projects_mirrored_with_pipelines_enabled
ci_internal_pipelines
ci_external_pipelines
ci_pipeline_config_auto_devops
......
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