Commit e09eabb2 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '321634-drop-at-most' into 'master'

Remove at_most helper on ApplicationRecord

See merge request gitlab-org/gitlab!54555
parents 80ed7104 95b1b3ea
......@@ -27,7 +27,7 @@ module AlertManagement
first_id = project.alert_management_http_integrations
.ordered_by_id
.select(:id)
.at_most(1)
.limit(1)
@collection = collection.id_in(first_id)
end
......
......@@ -42,10 +42,6 @@ class ApplicationRecord < ActiveRecord::Base
false
end
def self.at_most(count)
limit(count)
end
def self.safe_find_or_create_by!(*args, &block)
safe_find_or_create_by(*args, &block).tap do |record|
raise ActiveRecord::RecordNotFound unless record.present?
......
......@@ -17,7 +17,7 @@ module MergeRequests
.opened
.by_target_branch(merge_request.source_branch)
.preload_source_project
.at_most(MAX_RETARGET_MERGE_REQUESTS)
.limit(MAX_RETARGET_MERGE_REQUESTS)
other_merge_requests.find_each do |other_merge_request|
# Update only MRs on projects that we have access to
......
......@@ -48,7 +48,7 @@ module NetworkPolicies
if environment_id
Clusters::KubernetesNamespace.where(environment: project.environments.id_in(environment_id))
else
Clusters::KubernetesNamespace.where(environment: project.environments.available.at_most(LIMIT))
Clusters::KubernetesNamespace.where(environment: project.environments.available.limit(LIMIT))
end
kubernetes_namespaces
......
......@@ -38,7 +38,7 @@ module Gitlab
def fetch_page(relation)
relation = relation.by_updated_at
notes = relation.at_most(LIMIT + 1).to_a
notes = relation.limit(LIMIT + 1).to_a
return [notes, false] unless notes.size > LIMIT
......
......@@ -93,13 +93,6 @@ RSpec.describe ApplicationRecord do
end
end
describe '.at_most' do
it 'limits the number of records returned' do
create_list(:user, 3)
expect(User.at_most(2).count).to eq(2)
end
end
describe '.where_exists' do
it 'produces a WHERE EXISTS query' do
user = create(:user)
......
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