diff options
author | James Lopez <james@gitlab.com> | 2019-04-04 10:31:24 +0300 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-04 10:31:24 +0300 |
commit | a6a3eb813fab81359ed0b81a25929d10766d25dc (patch) | |
tree | a3dc6dee42630b6c1829381bdb933a8bfdb27a7d /lib | |
parent | d0a0d3d3d5043d1497a5cd42e6c6bc073f6a5b58 (diff) | |
parent | ab1e1b55a84ffc6b09233a6831be9bdc77c05115 (diff) |
Merge branch 'support-time-windows-api' into 'master'
Support time window parameters in additional metrics endpoint
See merge request gitlab-org/gitlab-ce!26228
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb index 34b705138ba..c49877ddf9d 100644 --- a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb +++ b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb @@ -7,12 +7,16 @@ module Gitlab include QueryAdditionalMetrics # rubocop: disable CodeReuse/ActiveRecord - def query(environment_id) + def query(environment_id, timeframe_start = 8.hours.ago, timeframe_end = Time.now) ::Environment.find_by(id: environment_id).try do |environment| query_metrics( environment.project, environment, - common_query_context(environment, timeframe_start: 8.hours.ago.to_f, timeframe_end: Time.now.to_f) + common_query_context( + environment, + timeframe_start: timeframe_start.to_f, + timeframe_end: timeframe_end.to_f + ) ) end end |