Class: GitLab::Monitor::Database::RemoteMirrorsCollector

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab_monitor/database/remote_mirrors.rb

Overview

A helper class to collect remote mirrors metrics.

Constant Summary collapse

QUERY =
<<~SQL.freeze
  SELECT project_id, url,
  EXTRACT(EPOCH FROM last_successful_update_at) AS last_successful_update_at,
  EXTRACT(EPOCH FROM last_update_at) AS last_update_at
  FROM remote_mirrors WHERE project_id IN (%s) AND enabled = 't'
SQL

Instance Method Summary collapse

Methods inherited from Base

connection_pool, #connection_pool, #with_connection_pool

Constructor Details

#initialize(args) ⇒ RemoteMirrorsCollector

Returns a new instance of RemoteMirrorsCollector.



13
14
15
16
17
# File 'lib/gitlab_monitor/database/remote_mirrors.rb', line 13

def initialize(args)
  super(args)

  @project_ids = args[:project_ids]
end

Instance Method Details

#runObject



19
20
21
22
23
# File 'lib/gitlab_monitor/database/remote_mirrors.rb', line 19

def run
  return if @project_ids.nil? || @project_ids.empty?

  execute(QUERY % [@project_ids.join(",")]) # rubocop:disable Style/FormatString
end