summaryrefslogtreecommitdiff
path: root/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
blob: fa86d2dfd6caf27e07519043f7335d37b217a25b (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
module Gitlab
  module Prometheus
    module Queries
      class AdditionalMetricsDeploymentQuery < BaseQuery
        include QueryAdditionalMetrics

        # rubocop: disable CodeReuse/ActiveRecord
        def query(deployment_id)
          Deployment.find_by(id: deployment_id).try do |deployment|
            query_metrics(
              deployment.project,
              deployment.environment,
              common_query_context(
                deployment.environment,
                timeframe_start: (deployment.created_at - 30.minutes).to_f,
                timeframe_end: (deployment.created_at + 30.minutes).to_f
              )
            )
          end
        end
        # rubocop: enable CodeReuse/ActiveRecord
      end
    end
  end
end