Commit d509f0e1 authored by Shubham Kumar's avatar Shubham Kumar Committed by Heinrich Lee Yu

Resolves rubocop offense Rails/WhereEquals

Fixes auto correct rubocop offenses
parent e77edc54
...@@ -626,11 +626,6 @@ Rails/SkipsModelValidations: ...@@ -626,11 +626,6 @@ Rails/SkipsModelValidations:
Rails/SquishedSQLHeredocs: Rails/SquishedSQLHeredocs:
Enabled: false Enabled: false
# Offense count: 44
# Cop supports --auto-correct.
Rails/WhereEquals:
Enabled: false
# Offense count: 44 # Offense count: 44
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.
......
...@@ -133,7 +133,7 @@ module Ci ...@@ -133,7 +133,7 @@ module Ci
when true when true
items.where.not(yaml_errors: nil) items.where.not(yaml_errors: nil)
when false when false
items.where("yaml_errors IS NULL") items.where(yaml_errors: nil)
else else
items items
end end
......
...@@ -28,7 +28,7 @@ module Milestoneable ...@@ -28,7 +28,7 @@ module Milestoneable
scope :without_release, -> do scope :without_release, -> do
joins("LEFT OUTER JOIN milestone_releases ON #{table_name}.milestone_id = milestone_releases.milestone_id") joins("LEFT OUTER JOIN milestone_releases ON #{table_name}.milestone_id = milestone_releases.milestone_id")
.where('milestone_releases.release_id IS NULL') .where(milestone_releases: { release_id: nil })
end end
scope :joins_milestone_releases, -> do scope :joins_milestone_releases, -> do
......
...@@ -12,7 +12,7 @@ class DeploymentMergeRequest < ApplicationRecord ...@@ -12,7 +12,7 @@ class DeploymentMergeRequest < ApplicationRecord
end end
def self.by_deployment_id(id) def self.by_deployment_id(id)
where('deployments.id = ?', id) where(deployments: { id: id })
end end
def self.deployed_to(name) def self.deployed_to(name)
...@@ -20,7 +20,7 @@ class DeploymentMergeRequest < ApplicationRecord ...@@ -20,7 +20,7 @@ class DeploymentMergeRequest < ApplicationRecord
# (project_id, name), instead of using the index on # (project_id, name), instead of using the index on
# (name varchar_pattern_ops). This results in better performance on # (name varchar_pattern_ops). This results in better performance on
# GitLab.com. # GitLab.com.
where('environments.name = ?', name) where(environments: { name: name })
.where('environments.project_id = merge_requests.target_project_id') .where('environments.project_id = merge_requests.target_project_id')
end end
......
...@@ -109,13 +109,13 @@ class Group < Namespace ...@@ -109,13 +109,13 @@ class Group < Namespace
scope :for_authorized_group_members, -> (user_ids) do scope :for_authorized_group_members, -> (user_ids) do
joins(:group_members) joins(:group_members)
.where("members.user_id IN (?)", user_ids) .where(members: { user_id: user_ids })
.where("access_level >= ?", Gitlab::Access::GUEST) .where("access_level >= ?", Gitlab::Access::GUEST)
end end
scope :for_authorized_project_members, -> (user_ids) do scope :for_authorized_project_members, -> (user_ids) do
joins(projects: :project_authorizations) joins(projects: :project_authorizations)
.where("project_authorizations.user_id IN (?)", user_ids) .where(project_authorizations: { user_id: user_ids })
end end
class << self class << self
...@@ -153,7 +153,7 @@ class Group < Namespace ...@@ -153,7 +153,7 @@ class Group < Namespace
def select_for_project_authorization def select_for_project_authorization
if current_scope.joins_values.include?(:shared_projects) if current_scope.joins_values.include?(:shared_projects)
joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id') joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id')
.where('project_namespace.share_with_group_lock = ?', false) .where(project_namespace: { share_with_group_lock: false })
.select("projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level") .select("projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level")
else else
super super
......
...@@ -8,7 +8,7 @@ class IssueAssignee < ApplicationRecord ...@@ -8,7 +8,7 @@ class IssueAssignee < ApplicationRecord
validates :assignee, uniqueness: { scope: :issue_id } validates :assignee, uniqueness: { scope: :issue_id }
scope :in_projects, ->(project_ids) { joins(:issue).where("issues.project_id in (?)", project_ids) } scope :in_projects, ->(project_ids) { joins(:issue).where(issues: { project_id: project_ids }) }
scope :on_issues, ->(issue_ids) { where(issue_id: issue_ids) } scope :on_issues, ->(issue_ids) { where(issue_id: issue_ids) }
scope :for_assignee, ->(user) { where(assignee: user) } scope :for_assignee, ->(user) { where(assignee: user) }
end end
......
...@@ -16,7 +16,7 @@ class ProjectMember < Member ...@@ -16,7 +16,7 @@ class ProjectMember < Member
scope :in_project, ->(project) { where(source_id: project.id) } scope :in_project, ->(project) { where(source_id: project.id) }
scope :in_namespaces, ->(groups) do scope :in_namespaces, ->(groups) do
joins('INNER JOIN projects ON projects.id = members.source_id') joins('INNER JOIN projects ON projects.id = members.source_id')
.where('projects.namespace_id in (?)', groups.select(:id)) .where(projects: { namespace_id: groups.select(:id) })
end end
scope :without_project_bots, -> do scope :without_project_bots, -> do
......
...@@ -6,5 +6,5 @@ class MergeRequestAssignee < ApplicationRecord ...@@ -6,5 +6,5 @@ class MergeRequestAssignee < ApplicationRecord
validates :assignee, uniqueness: { scope: :merge_request_id } validates :assignee, uniqueness: { scope: :merge_request_id }
scope :in_projects, ->(project_ids) { joins(:merge_request).where("merge_requests.target_project_id in (?)", project_ids) } scope :in_projects, ->(project_ids) { joins(:merge_request).where(merge_requests: { target_project_id: project_ids }) }
end end
...@@ -94,7 +94,7 @@ class Milestone < ApplicationRecord ...@@ -94,7 +94,7 @@ class Milestone < ApplicationRecord
end end
def participants def participants
User.joins(assigned_issues: :milestone).where("milestones.id = ?", id).distinct User.joins(assigned_issues: :milestone).where(milestones: { id: id }).distinct
end end
def self.sort_by_attribute(method) def self.sort_by_attribute(method)
......
...@@ -89,7 +89,7 @@ class Namespace < ApplicationRecord ...@@ -89,7 +89,7 @@ class Namespace < ApplicationRecord
before_destroy(prepend: true) { prepare_for_destroy } before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir after_destroy :rm_dir
scope :for_user, -> { where('type IS NULL') } scope :for_user, -> { where(type: nil) }
scope :sort_by_type, -> { order(Gitlab::Database.nulls_first_order(:type)) } scope :sort_by_type, -> { order(Gitlab::Database.nulls_first_order(:type)) }
scope :include_route, -> { includes(:route) } scope :include_route, -> { includes(:route) }
scope :by_parent, -> (parent) { where(parent_id: parent) } scope :by_parent, -> (parent) { where(parent_id: parent) }
......
...@@ -27,7 +27,7 @@ module Network ...@@ -27,7 +27,7 @@ module Network
@project @project
.notes .notes
.where('noteable_type = ?', 'Commit') .where(noteable_type: 'Commit')
.group('notes.commit_id') .group('notes.commit_id')
.select('notes.commit_id, count(notes.id) as note_count') .select('notes.commit_id, count(notes.id) as note_count')
.each do |item| .each do |item|
......
...@@ -97,7 +97,7 @@ module Operations ...@@ -97,7 +97,7 @@ module Operations
issues = ::Issue issues = ::Issue
.select('issues.*, operations_feature_flags_issues.id AS link_id') .select('issues.*, operations_feature_flags_issues.id AS link_id')
.joins(:feature_flag_issues) .joins(:feature_flag_issues)
.where('operations_feature_flags_issues.feature_flag_id = ?', id) .where(operations_feature_flags_issues: { feature_flag_id: id })
.order('operations_feature_flags_issues.id ASC') .order('operations_feature_flags_issues.id ASC')
.includes(preload) .includes(preload)
......
...@@ -118,7 +118,7 @@ class Snippet < ApplicationRecord ...@@ -118,7 +118,7 @@ class Snippet < ApplicationRecord
def self.only_include_projects_visible_to(current_user = nil) def self.only_include_projects_visible_to(current_user = nil)
levels = Gitlab::VisibilityLevel.levels_for_user(current_user) levels = Gitlab::VisibilityLevel.levels_for_user(current_user)
joins(:project).where('projects.visibility_level IN (?)', levels) joins(:project).where(projects: { visibility_level: levels })
end end
def self.only_include_projects_with_snippets_enabled(include_private: false) def self.only_include_projects_with_snippets_enabled(include_private: false)
......
...@@ -129,7 +129,7 @@ module Boards ...@@ -129,7 +129,7 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def label_links(label_ids) def label_links(label_ids)
LabelLink LabelLink
.where('label_links.target_type = ?', item_model) .where(label_links: { target_type: item_model })
.where(item_model.arel_table[:id].eq(LabelLink.arel_table[:target_id]).to_sql) .where(item_model.arel_table[:id].eq(LabelLink.arel_table[:target_id]).to_sql)
.where(label_id: label_ids) .where(label_id: label_ids)
end end
......
...@@ -37,7 +37,7 @@ module Todos ...@@ -37,7 +37,7 @@ module Todos
def todos def todos
Todo.joins_issue_and_assignees Todo.joins_issue_and_assignees
.where(target: issues) .where(target: issues)
.where('issues.confidential = ?', true) .where(issues: { confidential: true })
.where('todos.user_id != issues.author_id') .where('todos.user_id != issues.author_id')
.where('todos.user_id != issue_assignees.user_id') .where('todos.user_id != issue_assignees.user_id')
end end
......
---
title: Resolves rubocop offenses Rails/WhereEquals
merge_request: 58067
author: Shubham Kumar (@imskr)
type: fixed
...@@ -82,12 +82,12 @@ class CleanupProjectsWithMissingNamespace < ActiveRecord::Migration[6.0] ...@@ -82,12 +82,12 @@ class CleanupProjectsWithMissingNamespace < ActiveRecord::Migration[6.0]
# There should only be one Group for User Ghost starting with LOST_AND_FOUND_GROUP # There should only be one Group for User Ghost starting with LOST_AND_FOUND_GROUP
Group Group
.joins('INNER JOIN members ON namespaces.id = members.source_id') .joins('INNER JOIN members ON namespaces.id = members.source_id')
.where('namespaces.type = ?', 'Group') .where(namespaces: { type: 'Group' })
.where('members.type = ?', 'GroupMember') .where(members: { type: 'GroupMember' })
.where('members.source_type = ?', 'Namespace') .where(members: { source_type: 'Namespace' })
.where('members.user_id = ?', self.id) .where(members: { user_id: self.id })
.where('members.requested_at IS NULL') .where(members: { requested_at: nil })
.where('members.access_level = ?', ACCESS_LEVEL_OWNER) .where(members: { access_level: ACCESS_LEVEL_OWNER })
.find_by(Group.arel_table[:name].matches("#{LOST_AND_FOUND_GROUP}%")) .find_by(Group.arel_table[:name].matches("#{LOST_AND_FOUND_GROUP}%"))
end end
......
...@@ -25,11 +25,11 @@ class UpdateRoutesForLostAndFoundGroupAndOrphanedProjects < ActiveRecord::Migrat ...@@ -25,11 +25,11 @@ class UpdateRoutesForLostAndFoundGroupAndOrphanedProjects < ActiveRecord::Migrat
# There should only be one Group owned by the Ghost user starting with 'lost-and-found' # There should only be one Group owned by the Ghost user starting with 'lost-and-found'
Group Group
.joins('INNER JOIN members ON namespaces.id = members.source_id') .joins('INNER JOIN members ON namespaces.id = members.source_id')
.where('namespaces.type = ?', 'Group') .where(namespaces: { type: 'Group' })
.where('members.type = ?', 'GroupMember') .where(members: { type: 'GroupMember' })
.where('members.source_type = ?', 'Namespace') .where(members: { source_type: 'Namespace' })
.where('members.user_id = ?', self.id) .where(members: { user_id: self.id })
.where('members.access_level = ?', ACCESS_LEVEL_OWNER) .where(members: { access_level: ACCESS_LEVEL_OWNER })
.find_by(Group.arel_table[:name].matches("#{LOST_AND_FOUND_GROUP}%")) .find_by(Group.arel_table[:name].matches("#{LOST_AND_FOUND_GROUP}%"))
end end
......
...@@ -36,7 +36,7 @@ class GenerateMissingRoutesForBots < ActiveRecord::Migration[6.0] ...@@ -36,7 +36,7 @@ class GenerateMissingRoutesForBots < ActiveRecord::Migration[6.0]
belongs_to :owner, class_name: 'GenerateMissingRoutesForBots::User' belongs_to :owner, class_name: 'GenerateMissingRoutesForBots::User'
scope :for_user, -> { where('type IS NULL') } scope :for_user, -> { where(type: nil) }
scope :for_bots, -> { for_user.joins(:owner).merge(GenerateMissingRoutesForBots::User.bots) } scope :for_bots, -> { for_user.joins(:owner).merge(GenerateMissingRoutesForBots::User.bots) }
scope :without_routes, -> do scope :without_routes, -> do
......
...@@ -71,7 +71,7 @@ class CleanupGroupImportStatesWithNullUserId < ActiveRecord::Migration[6.0] ...@@ -71,7 +71,7 @@ class CleanupGroupImportStatesWithNullUserId < ActiveRecord::Migration[6.0]
end end
end end
GroupImportState.where('user_id IS NULL').delete_all GroupImportState.where(user_id: nil).delete_all
end end
def down def down
......
...@@ -21,7 +21,7 @@ class EnsureU2fRegistrationsMigrated < ActiveRecord::Migration[6.0] ...@@ -21,7 +21,7 @@ class EnsureU2fRegistrationsMigrated < ActiveRecord::Migration[6.0]
# Do a manual update in case we lost BG jobs. The expected record count should be 0 or very low. # Do a manual update in case we lost BG jobs. The expected record count should be 0 or very low.
U2fRegistration U2fRegistration
.joins("LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id") .joins("LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id")
.where("webauthn_registrations.u2f_registration_id IS NULL") .where(webauthn_registrations: { u2f_registration_id: nil })
.each_batch(of: BATCH_SIZE) do |batch, index| .each_batch(of: BATCH_SIZE) do |batch, index|
batch.each do |record| batch.each do |record|
Gitlab::BackgroundMigration::MigrateU2fWebauthn.new.perform(record.id, record.id) Gitlab::BackgroundMigration::MigrateU2fWebauthn.new.perform(record.id, record.id)
......
...@@ -15,7 +15,7 @@ class CleanupGitlabSubscriptionsWithNullNamespaceId < ActiveRecord::Migration[6. ...@@ -15,7 +15,7 @@ class CleanupGitlabSubscriptionsWithNullNamespaceId < ActiveRecord::Migration[6.
# This will be fast on GitLab.com, because: # This will be fast on GitLab.com, because:
# - gitlab_subscriptions.count=5021850 # - gitlab_subscriptions.count=5021850
# - namespace_id is indexed, so the query is pretty fast. Try on database-lab, this uses 5.931 ms # - namespace_id is indexed, so the query is pretty fast. Try on database-lab, this uses 5.931 ms
GitlabSubscription.where('namespace_id IS NULL').delete_all GitlabSubscription.where(namespace_id: nil).delete_all
end end
def down def down
......
...@@ -15,7 +15,7 @@ class CleanupClusterTokensWithNullName < ActiveRecord::Migration[6.0] ...@@ -15,7 +15,7 @@ class CleanupClusterTokensWithNullName < ActiveRecord::Migration[6.0]
def up def up
AgentToken.each_batch(of: BATCH_SIZE) do |relation| AgentToken.each_batch(of: BATCH_SIZE) do |relation|
relation.where('name IS NULL').update_all("name = 'agent-token-' || id") relation.where(name: nil).update_all("name = 'agent-token-' || id")
end end
end end
......
...@@ -17,7 +17,7 @@ class BackfillEventsIdForBigintConversion < ActiveRecord::Migration[6.0] ...@@ -17,7 +17,7 @@ class BackfillEventsIdForBigintConversion < ActiveRecord::Migration[6.0]
Gitlab::Database::BackgroundMigration::BatchedMigration Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'events', column_name: 'id') .where(table_name: 'events', column_name: 'id')
.where('job_arguments = ?', %w[id id_convert_to_bigint].to_json) .where(job_arguments: %w[id id_convert_to_bigint].to_json)
.delete_all .delete_all
end end
......
...@@ -18,7 +18,7 @@ class BackfillPushEventPayloadEventIdForBigintConversion < ActiveRecord::Migrati ...@@ -18,7 +18,7 @@ class BackfillPushEventPayloadEventIdForBigintConversion < ActiveRecord::Migrati
Gitlab::Database::BackgroundMigration::BatchedMigration Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'push_event_payloads', column_name: 'event_id') .where(table_name: 'push_event_payloads', column_name: 'event_id')
.where('job_arguments = ?', %w[event_id event_id_convert_to_bigint].to_json) .where(job_arguments: %w[event_id event_id_convert_to_bigint].to_json)
.delete_all .delete_all
end end
......
...@@ -18,7 +18,7 @@ class BackfillCiBuildNeedsForBigintConversion < ActiveRecord::Migration[6.0] ...@@ -18,7 +18,7 @@ class BackfillCiBuildNeedsForBigintConversion < ActiveRecord::Migration[6.0]
Gitlab::Database::BackgroundMigration::BatchedMigration Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'ci_build_needs', column_name: 'build_id') .where(table_name: 'ci_build_needs', column_name: 'build_id')
.where('job_arguments = ?', %w[build_id build_id_convert_to_bigint].to_json) .where(job_arguments: %w[build_id build_id_convert_to_bigint].to_json)
.delete_all .delete_all
end end
......
...@@ -17,7 +17,7 @@ class BackfillConversionOfCiJobArtifacts < ActiveRecord::Migration[6.0] ...@@ -17,7 +17,7 @@ class BackfillConversionOfCiJobArtifacts < ActiveRecord::Migration[6.0]
Gitlab::Database::BackgroundMigration::BatchedMigration Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'ci_job_artifacts', column_name: 'id') .where(table_name: 'ci_job_artifacts', column_name: 'id')
.where('job_arguments = ?', [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]].to_json) .where(job_arguments: [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]].to_json)
.delete_all .delete_all
end end
......
...@@ -16,7 +16,7 @@ class BackfillCiSourcesPipelinesSourceJobIdForBigintConversion < ActiveRecord::M ...@@ -16,7 +16,7 @@ class BackfillCiSourcesPipelinesSourceJobIdForBigintConversion < ActiveRecord::M
Gitlab::Database::BackgroundMigration::BatchedMigration Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'ci_sources_pipelines', column_name: 'id') .where(table_name: 'ci_sources_pipelines', column_name: 'id')
.where('job_arguments = ?', [%w[source_job_id], %w[source_job_id_convert_to_bigint]].to_json) .where(job_arguments: [%w[source_job_id], %w[source_job_id_convert_to_bigint]].to_json)
.delete_all .delete_all
end end
......
...@@ -35,7 +35,7 @@ module EE ...@@ -35,7 +35,7 @@ module EE
return self.all unless ::Gitlab::Geo.current_node.selective_sync? return self.all unless ::Gitlab::Geo.current_node.selective_sync?
self.joins(:package) self.joins(:package)
.where('packages_packages.project_id IN (?)', ::Gitlab::Geo.current_node.projects.select(:id)) .where(packages_packages: { project_id: ::Gitlab::Geo.current_node.projects.select(:id) })
end end
end end
......
...@@ -286,7 +286,7 @@ module EE ...@@ -286,7 +286,7 @@ module EE
def with_slack_application_disabled def with_slack_application_disabled
joins('LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true') joins('LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true')
.where('services.id IS NULL') .where(services: { id: nil })
end end
override :with_web_entity_associations override :with_web_entity_associations
......
...@@ -32,7 +32,7 @@ module EE ...@@ -32,7 +32,7 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def label_links(label_ids) def label_links(label_ids)
if has_valid_milestone? if has_valid_milestone?
super.where("issues.milestone_id = ?", board.milestone_id) super.where(issues: { milestone_id: board.milestone_id })
else else
super super
end end
......
...@@ -479,7 +479,7 @@ module EE ...@@ -479,7 +479,7 @@ module EE
::Security::Scan.scan_types.each do |name, scan_type| ::Security::Scan.scan_types.each do |name, scan_type|
relation = ::Ci::Build.joins(:security_scans) relation = ::Ci::Build.joins(:security_scans)
.where(status: 'success', retried: [nil, false]) .where(status: 'success', retried: [nil, false])
.where('security_scans.scan_type = ?', scan_type) .where(security_scans: { scan_type: scan_type })
.where(time_period) .where(time_period)
pipelines_with_secure_jobs["#{name}_pipeline".to_sym] = distinct_count(relation, :commit_id, start: start, finish: finish, batch: false) pipelines_with_secure_jobs["#{name}_pipeline".to_sym] = distinct_count(relation, :commit_id, start: start, finish: finish, batch: false)
end end
......
...@@ -182,7 +182,7 @@ namespace :gitlab do ...@@ -182,7 +182,7 @@ namespace :gitlab do
relation = Project.all relation = Project.all
unless ENV['UPDATE_INDEX'] unless ENV['UPDATE_INDEX']
relation = relation.includes(:index_status).where('index_statuses.id IS NULL').references(:index_statuses) relation = relation.includes(:index_status).where(index_statuses: { id: nil }).references(:index_statuses)
end end
if ::Gitlab::CurrentSettings.elasticsearch_limit_indexing? if ::Gitlab::CurrentSettings.elasticsearch_limit_indexing?
......
...@@ -19,7 +19,7 @@ module Banzai ...@@ -19,7 +19,7 @@ module Banzai
def readable_project_ids_for(user) def readable_project_ids_for(user)
@project_ids_by_user ||= {} @project_ids_by_user ||= {}
@project_ids_by_user[user] ||= @project_ids_by_user[user] ||=
Project.public_or_visible_to_user(user).where("projects.id IN (?)", @projects_for_nodes.values.map(&:id)).pluck(:id) Project.public_or_visible_to_user(user).where(projects: { id: @projects_for_nodes.values.map(&:id) }).pluck(:id)
end end
def can_read_reference?(user, ref_project, node) def can_read_reference?(user, ref_project, node)
......
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
scope :for_migration_class, -> (class_name) { where(class_name: normalize_class_name(class_name)) } scope :for_migration_class, -> (class_name) { where(class_name: normalize_class_name(class_name)) }
scope :for_migration_execution, -> (class_name, arguments) do scope :for_migration_execution, -> (class_name, arguments) do
for_migration_class(class_name).where('arguments = ?', arguments.to_json) for_migration_class(class_name).where('arguments = ?', arguments.to_json) # rubocop:disable Rails/WhereEquals
end end
scope :for_partitioning_migration, -> (class_name, table_name) do scope :for_partitioning_migration, -> (class_name, table_name) do
......
...@@ -95,12 +95,12 @@ RSpec.describe CleanupProjectsWithMissingNamespace, :migration, schema: SchemaVe ...@@ -95,12 +95,12 @@ RSpec.describe CleanupProjectsWithMissingNamespace, :migration, schema: SchemaVe
expect( expect(
described_class::Group described_class::Group
.joins('INNER JOIN members ON namespaces.id = members.source_id') .joins('INNER JOIN members ON namespaces.id = members.source_id')
.where('namespaces.type = ?', 'Group') .where(namespaces: { type: 'Group' })
.where('members.type = ?', 'GroupMember') .where(members: { type: 'GroupMember' })
.where('members.source_type = ?', 'Namespace') .where(members: { source_type: 'Namespace' })
.where('members.user_id = ?', ghost_user.id) .where(members: { user_id: ghost_user.id })
.where('members.requested_at IS NULL') .where(members: { requested_at: nil })
.where('members.access_level = ?', described_class::ACCESS_LEVEL_OWNER) .where(members: { access_level: described_class::ACCESS_LEVEL_OWNER })
.where( .where(
described_class::Group described_class::Group
.arel_table[:name] .arel_table[:name]
......
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