Commit 1b7c1867 authored by James Lopez's avatar James Lopez

move query limit to base event fetcher

parent 58a5d4a9
...@@ -5,6 +5,8 @@ module Gitlab ...@@ -5,6 +5,8 @@ module Gitlab
attr_reader :projections, :query, :stage, :order attr_reader :projections, :query, :stage, :order
MAX_EVENTS = 50
def initialize(project:, stage:, options:) def initialize(project:, stage:, options:)
@project = project @project = project
@stage = stage @stage = stage
...@@ -38,7 +40,7 @@ module Gitlab ...@@ -38,7 +40,7 @@ module Gitlab
def events_query def events_query
diff_fn = subtract_datetimes_diff(base_query, @options[:start_time_attrs], @options[:end_time_attrs]) diff_fn = subtract_datetimes_diff(base_query, @options[:start_time_attrs], @options[:end_time_attrs])
base_query.project(extract_diff_epoch(diff_fn).as('total_time'), *projections).order(order.desc) base_query.project(extract_diff_epoch(diff_fn).as('total_time'), *projections).order(order.desc).take(MAX_EVENTS)
end end
def default_order def default_order
......
Markdown is supported
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