diff options
Diffstat (limited to 'app/finders/deployments_finder.rb')
-rw-r--r-- | app/finders/deployments_finder.rb | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/app/finders/deployments_finder.rb b/app/finders/deployments_finder.rb index 21869f6f31d..316dffcb3b2 100644 --- a/app/finders/deployments_finder.rb +++ b/app/finders/deployments_finder.rb @@ -14,6 +14,8 @@ # order_by: String (see ALLOWED_SORT_VALUES constant) # sort: String (asc | desc) class DeploymentsFinder + include UpdatedAtFilter + attr_reader :params # Warning: @@ -50,10 +52,6 @@ class DeploymentsFinder private - def raise_for_inefficient_updated_at_query? - params.fetch(:raise_for_inefficient_updated_at_query, Rails.env.development? || Rails.env.test?) - end - def validate! if filter_by_updated_at? && filter_by_finished_at? raise InefficientQueryError, 'Both `updated_at` filter and `finished_at` filter can not be specified' @@ -61,12 +59,20 @@ class DeploymentsFinder # Currently, the inefficient parameters are allowed in order to avoid breaking changes in Deployment API. # We'll switch to a hard error in https://gitlab.com/gitlab-org/gitlab/-/issues/328500. - if (filter_by_updated_at? && !order_by_updated_at?) || (!filter_by_updated_at? && order_by_updated_at?) - error = InefficientQueryError.new('`updated_at` filter and `updated_at` sorting must be paired') + if filter_by_updated_at? && !order_by_updated_at? + error = InefficientQueryError.new('`updated_at` filter requires `updated_at` sort') Gitlab::ErrorTracking.log_exception(error) - raise error if raise_for_inefficient_updated_at_query? + # We are adding a Feature Flag to introduce the breaking change indicated in + # https://gitlab.com/gitlab-org/gitlab/-/issues/328500 + # We are also adding a way to override this flag for special case users that + # are running into large volume of errors when the flag is enabled. + # These Feature Flags must be removed by 16.1 + if Feature.enabled?(:deployments_raise_updated_at_inefficient_error) && + Feature.disabled?(:deployments_raise_updated_at_inefficient_error_override, params[:project]) + raise error + end end if filter_by_finished_at? && !order_by_finished_at? @@ -109,13 +115,6 @@ class DeploymentsFinder items.order(sort_params) # rubocop: disable CodeReuse/ActiveRecord end - def by_updated_at(items) - items = items.updated_before(params[:updated_before]) if params[:updated_before].present? - items = items.updated_after(params[:updated_after]) if params[:updated_after].present? - - items - end - def by_finished_at(items) items = items.finished_before(params[:finished_before]) if params[:finished_before].present? items = items.finished_after(params[:finished_after]) if params[:finished_after].present? |