Commit 01e5b4be authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Merge branch 'fix-remote-mirrors-exporter' into 'master'

Fix plan checks for mirror queries

See merge request gitlab-org/gitlab-exporter!110
parents 722c0351 54bf45dc
Pipeline #149826 passed with stage
in 46 seconds
......@@ -8,6 +8,7 @@ module GitLab
# This class works under the assumption you do COUNT(*) queries, define
# queries in the QUERIES constant. If in doubt how these work, read
# #construct_query
# rubocop:disable Metrics/ClassLength
class RowCountCollector < Base
projects.mirror = true
......@@ -19,8 +20,15 @@ module GitLab
select: :projects,
joins: <<~SQL,
INNER JOIN project_mirror_data ON project_mirror_data.project_id =
INNER JOIN namespaces ON projects.namespace_id =
LEFT JOIN plans ON namespaces.plan_id =
INNER JOIN namespaces AS root_namespaces ON = (
WITH RECURSIVE "base_and_ancestors" AS (
(SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = projects.namespace_id)
(SELECT "namespaces".* FROM "namespaces", "base_and_ancestors" WHERE "namespaces"."id" = "base_and_ancestors"."parent_id")
) SELECT "namespaces".id FROM "base_and_ancestors" AS "namespaces" WHERE "namespaces"."parent_id" IS NULL
LEFT JOIN gitlab_subscriptions ON gitlab_subscriptions.namespace_id =
LEFT JOIN plans ON = gitlab_subscriptions.hosted_plan_id
check: "SELECT 1 FROM information_schema.tables WHERE table_name='plans'"
......@@ -189,6 +197,7 @@ module GitLab
query_string << ";"
# rubocop:enable Metrics/ClassLength
# The prober which is called when gathering metrics
class RowCountProber
Supports Markdown
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