Welcome to mirror list, hosted at ThFree Co, Russian Federation.

batched_background_migration_failed_jobs_metric.rb « instrumentations « metrics « usage « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f5d963cf52271de0c48cb1a202d9f8ce03798d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module Gitlab
  module Usage
    module Metrics
      module Instrumentations
        class BatchedBackgroundMigrationFailedJobsMetric < DatabaseMetric
          relation do
            Gitlab::Database::BackgroundMigration::BatchedMigration
              .joins(:batched_jobs)
              .where(batched_jobs: { status: '2' })
              .group(%w[table_name job_class_name])
              .order(%w[table_name job_class_name])
              .select(['table_name', 'job_class_name', 'COUNT(batched_jobs) AS number_of_failed_jobs'])
          end

          timestamp_column(:created_at)

          operation :count

          def value
            relation.map do |batched_migration|
              {
                job_class_name: batched_migration.job_class_name,
                table_name: batched_migration.table_name,
                number_of_failed_jobs: batched_migration.number_of_failed_jobs
              }
            end
          end
        end
      end
    end
  end
end