A platform for community discussion. Free, open, simple.
DEV: Hand-pick Rails/WhereNot autofixes (#35117)
Jarek Radosza54e3208cb1e
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex 358c5e2bb23..bb34a8e810e 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -1063,9 +1063,9 @@ class GroupsController < ApplicationControllercategories.each do |category_id, data|category_users = []existing_users =- CategoryUser.where(category_id: category_id, user_id: user_ids).where(- "notification_level IS NOT NULL",- )+ CategoryUser+ .where(category_id:, user_id: user_ids)+ .where.not(notification_level: nil)skip_user_ids = existing_users.pluck(:user_id)batch.each do |group_user|@@ -1089,9 +1089,7 @@ class GroupsController < ApplicationControllertags.each do |tag_id, data|tag_users = []existing_users =- TagUser.where(tag_id: tag_id, user_id: user_ids).where(- "notification_level IS NOT NULL",- )+ TagUser.where(tag_id:, user_id: user_ids).where.not(notification_level: nil)skip_user_ids = existing_users.pluck(:user_id)batch.each do |group_user|diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rbindex 1ebb061239c..19220197694 100644--- a/app/controllers/invites_controller.rb+++ b/app/controllers/invites_controller.rb@@ -459,10 +459,7 @@ class InvitesController < ApplicationControllerreturn render_json_error(I18n.t("rate_limiter.slow_down"))end- Invite- .pending(current_user)- .where("invites.email IS NOT NULL")- .find_each { |invite| invite.resend_invite }+ Invite.pending(current_user).where.not(email: nil).find_each { |invite| invite.resend_invite }render json: success_jsonenddiff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 6f5047dad04..a52fcd60093 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -1956,9 +1956,7 @@ class UsersController < ApplicationController)bookmark_list.load do |query|- if exclude_bookmark_ids.present?- query.where("bookmarks.id NOT IN (?)", exclude_bookmark_ids)- end+ query.where.not(id: exclude_bookmark_ids) if exclude_bookmark_ids.present?endend@@ -2020,7 +2018,7 @@ class UsersController < ApplicationControllergroups_messages_notification_level: :watching,) do |query|if exclude_topic_ids.present?- query.where("topics.id NOT IN (?)", exclude_topic_ids)+ query.where.not(id: exclude_topic_ids)elsequeryenddiff --git a/app/jobs/onceoff/fix_featured_link_for_topics.rb b/app/jobs/onceoff/fix_featured_link_for_topics.rbindex 0b4f67ab9f0..771bc3ba2d1 100644--- a/app/jobs/onceoff/fix_featured_link_for_topics.rb+++ b/app/jobs/onceoff/fix_featured_link_for_topics.rb@@ -4,7 +4,7 @@ module Jobsclass FixFeaturedLinkForTopics < ::Jobs::Onceoffdef execute_onceoff(args)Topic- .where("featured_link IS NOT NULL")+ .where.not(featured_link: nil).find_each do |topic|featured_link = topic.featured_linkdiff --git a/app/jobs/regular/notify_moved_posts.rb b/app/jobs/regular/notify_moved_posts.rbindex fe0af30ae19..5b480077632 100644--- a/app/jobs/regular/notify_moved_posts.rb+++ b/app/jobs/regular/notify_moved_posts.rb@@ -10,7 +10,7 @@ module JobsPost.includes(:user, :topic).where(id: args[:post_ids])- .where("user_id <> ?", args[:moved_by_id])+ .where.not(user_id: args[:moved_by_id]).order(post_number: :asc)return if posts.blank?diff --git a/app/jobs/regular/notify_reviewable.rb b/app/jobs/regular/notify_reviewable.rbindex ef41a3b0436..acdf62a88ad 100644--- a/app/jobs/regular/notify_reviewable.rb+++ b/app/jobs/regular/notify_reviewable.rb@@ -35,10 +35,7 @@ class Jobs::NotifyReviewable < ::Jobs::Basenotify_users(User.real.admins, all_updates[:admins])if reviewable.reviewable_by_moderator?- notify_users(- User.real.moderators.where("id NOT IN (?)", @contacted),- all_updates[:moderators],- )+ notify_users(User.real.moderators.where.not(id: @contacted), all_updates[:moderators])endif SiteSetting.enable_category_group_moderation? && reviewable.category.present?@@ -50,7 +47,7 @@ class Jobs::NotifyReviewable < ::Jobs::Base"INNER JOIN category_moderation_groups ON category_moderation_groups.group_id = group_users.group_id",).where("category_moderation_groups.category_id": reviewable.category.id)- .where("users.id NOT IN (?)", @contacted)+ .where.not(id: @contacted).distinctusers.find_each do |user|diff --git a/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb b/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rbindex 319daa34692..3626cefbdce 100644--- a/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb+++ b/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb@@ -10,7 +10,7 @@ module Jobsclients =UserApiKeyClient- .where("auth_redirect IS NOT NULL")+ .where.not(auth_redirect: nil).where("id NOT IN (SELECT user_api_key_client_id FROM user_api_keys WHERE user_api_keys.last_used_at > ?)",destroy_days_ago,diff --git a/app/jobs/scheduled/fix_user_usernames_and_groups_names_clash.rb b/app/jobs/scheduled/fix_user_usernames_and_groups_names_clash.rbindex 471490be0f9..620f5ec0064 100644--- a/app/jobs/scheduled/fix_user_usernames_and_groups_names_clash.rb+++ b/app/jobs/scheduled/fix_user_usernames_and_groups_names_clash.rb@@ -7,7 +7,7 @@ module Jobsdef execute(args)User.joins("LEFT JOIN groups ON lower(groups.name) = users.username_lower")- .where("groups.id IS NOT NULL")+ .where.not(groups: { id: nil }).find_each do |user|suffix = 1old_username = user.usernamediff --git a/app/models/api_key.rb b/app/models/api_key.rbindex ba971d3ee67..cc19b120d61 100644--- a/app/models/api_key.rb+++ b/app/models/api_key.rb@@ -9,7 +9,7 @@ class ApiKey < ActiveRecord::Basebelongs_to :created_by, class_name: "User"scope :active, -> { where("revoked_at IS NULL") }- scope :revoked, -> { where("revoked_at IS NOT NULL") }+ scope :revoked, -> { where.not(revoked_at: nil) }scope :with_key,->(key) dodiff --git a/app/models/bookmark.rb b/app/models/bookmark.rbindex 6c4895e4228..64ac2decd39 100644--- a/app/models/bookmark.rb+++ b/app/models/bookmark.rb@@ -152,7 +152,7 @@ class Bookmark < ActiveRecord::Baseself.reminder_at.in_time_zone(timezone)end- scope :with_reminders, -> { where("reminder_at IS NOT NULL") }+ scope :with_reminders, -> { where.not(reminder_at: nil) }scope :pending_reminders,->(before_time = Time.now.utc) dodiff --git a/app/models/category.rb b/app/models/category.rbindex 9d7b54b8ea5..7c48540a669 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -572,7 +572,7 @@ class Category < ActiveRecord::BaseCategory.all.each do |c|topics = c.topics.visible- topics = topics.where(["topics.id <> ?", c.topic_id]) if c.topic_id+ topics = topics.where.not(id: c.topic_id) if c.topic_idc.topics_year = topics.created_since(1.year.ago).countc.topics_month = topics.created_since(1.month.ago).countc.topics_week = topics.created_since(1.week.ago).count@@ -596,7 +596,7 @@ class Category < ActiveRecord::Base.where("topics.visible = true").where("posts.deleted_at IS NULL").where("posts.user_deleted = false")- self.topic_id ? query.where(["topics.id <> ?", self.topic_id]) : query+ self.topic_id ? query.where.not(topics: { id: self.topic_id }) : queryend# Internal: Generate the text of post prompting to enter category description.@@ -916,7 +916,7 @@ class Category < ActiveRecord::Base.listable_topics.exclude_scheduled_bump_topics.where(category_id: self.id)- .where("id <> ?", self.topic_id)+ .where.not(id: self.topic_id).where("bumped_at < ?", (self.auto_bump_cooldown_days || 1).days.ago).where("pinned_at IS NULL AND NOT closed AND NOT archived").order("bumped_at ASC")@@ -1225,7 +1225,7 @@ class Category < ActiveRecord::BaseCategory.joins("LEFT JOIN topics ON categories.topic_id = topics.id AND topics.deleted_at IS NULL")- .where("categories.id <> ?", SiteSetting.uncategorized_category_id)+ .where.not(id: SiteSetting.uncategorized_category_id).where(topics: { id: nil }).find_each { |category| category.create_category_definition }enddiff --git a/app/models/discourse_connect.rb b/app/models/discourse_connect.rbindex 87e63bab134..ae50103d677 100644--- a/app/models/discourse_connect.rb+++ b/app/models/discourse_connect.rb@@ -190,14 +190,10 @@ class DiscourseConnect < DiscourseConnectBasedesired_groups = Group.where("LOWER(NAME) in (?) AND NOT automatic", names)to_be_added = desired_groups- if current_groups.present?- to_be_added = to_be_added.where("groups.id NOT IN (?)", current_groups.map(&:id))- end+ to_be_added = to_be_added.where.not(id: current_groups.map(&:id)) if current_groups.present?to_be_removed = current_groups- if desired_groups.present?- to_be_removed = to_be_removed.where("groups.id NOT IN (?)", desired_groups.map(&:id))- end+ to_be_removed = to_be_removed.where.not(id: desired_groups.map(&:id)) if desired_groups.present?if to_be_added.present? || to_be_removed.present?GroupUser.transaction do@@ -219,7 +215,7 @@ class DiscourseConnect < DiscourseConnectBaseif split.length > 0to_be_added = Group.where("LOWER(name) in (?) AND NOT automatic", split)if already_member = GroupUser.where(user_id: user.id).pluck(:group_id).presence- to_be_added = to_be_added.where("id NOT IN (?)", already_member)+ to_be_added = to_be_added.where.not(id: already_member)endendenddiff --git a/app/models/group.rb b/app/models/group.rbindex 34af51453cc..af656178b8a 100644--- a/app/models/group.rb+++ b/app/models/group.rb@@ -429,7 +429,7 @@ class Group < ActiveRecord::Base.preload(:topic, user: :groups, topic: :category).references(:posts, :topics, :category).where(groups: { id: id })- .where("topics.archetype <> ?", Archetype.private_message)+ .where.not(topics: { archetype: Archetype.private_message }).where("topics.visible").where(post_type: [Post.types[:regular], Post.types[:moderator_action]])@@ -450,7 +450,7 @@ class Group < ActiveRecord::Base.joins(:group_mentions).includes(:user, :topic, topic: :category).references(:posts, :topics, :category)- .where("topics.archetype <> ?", Archetype.private_message)+ .where.not(topics: { archetype: Archetype.private_message }).where(post_type: Post.types[:regular]).where("group_mentions.group_id = ?", self.id)diff --git a/app/models/invite.rb b/app/models/invite.rbindex e9800911049..f76b0512cd0 100644--- a/app/models/invite.rb+++ b/app/models/invite.rb@@ -277,7 +277,7 @@ class Invite < ActiveRecord::BaseInvitedUser.joins("LEFT JOIN invites ON invites.id = invited_users.invite_id").includes(user: :user_stat)- .where("invited_users.user_id IS NOT NULL")+ .where.not(user_id: nil).where("invites.invited_by_id = ?", inviter.id).order("invited_users.redeemed_at DESC").references("invite")diff --git a/app/models/notification.rb b/app/models/notification.rbindex 336a02b09b8..1d5cc9e08c1 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -290,7 +290,7 @@ class Notification < ActiveRecord::Baseelsif user.user_option.like_notification_frequency ==UserOption.like_notification_frequency_type[:never]like_types.each do |notification_type|- notifications = notifications.where("notification_type <> ?", notification_type)+ notifications = notifications.where.not(notification_type:)endendnotifications.to_a@@ -308,9 +308,7 @@ class Notification < ActiveRecord::Base[Notification.types[:liked],Notification.types[:liked_consolidated],- ].each do |notification_type|- notifications = notifications.where("notification_type <> ?", notification_type)- end+ ].each { |notification_type| notifications = notifications.where.not(notification_type:) }endnotifications = notifications.to_adiff --git a/app/models/post.rb b/app/models/post.rbindex c990302bf1a..c911f841253 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -112,7 +112,7 @@ class Post < ActiveRecord::Basescope :with_user, -> { includes(:user) }scope :created_since, ->(time_ago) { where("posts.created_at > ?", time_ago) }scope :public_posts,- -> { joins(:topic).where("topics.archetype <> ?", Archetype.private_message) }+ -> { joins(:topic).where.not(topics: { archetype: Archetype.private_message }) }scope :private_posts,-> { joins(:topic).where("topics.archetype = ?", Archetype.private_message) }scope :with_topic_subtype, ->(subtype) { joins(:topic).where("topics.subtype = ?", subtype) }diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rbindex cd030d4961a..435ddd37416 100644--- a/app/models/remote_theme.rb+++ b/app/models/remote_theme.rb@@ -138,7 +138,7 @@ class RemoteTheme < ActiveRecord::Baseif update_components == "sync"ChildTheme.joins(child_theme: :remote_theme)- .where("remote_themes.remote_url NOT IN (?)", child_components)+ .where.not(remote_themes: { remote_url: child_components }).delete_allend@@ -201,7 +201,7 @@ class RemoteTheme < ActiveRecord::Baseenddef self.unreachable_themes- self.joined_remotes.where("last_error_text IS NOT NULL").pluck("themes.name", "themes.id")+ self.joined_remotes.where.not(last_error_text: nil).pluck("themes.name", "themes.id")enddef out_of_date?diff --git a/app/models/search_log.rb b/app/models/search_log.rbindex 2a4bc540b5f..86cc0761e70 100644--- a/app/models/search_log.rb+++ b/app/models/search_log.rb@@ -94,7 +94,7 @@ class SearchLog < ActiveRecord::Baseresult = result.where("search_type = ?", search_types[search_type]) if search_type == :header ||search_type == :full_page- result = result.where("search_result_id IS NOT NULL") if search_type == :click_through_only+ result = result.where.not(search_result_id: nil) if search_type == :click_through_onlyresult.order("date")diff --git a/app/models/theme.rb b/app/models/theme.rbindex 74a6440729f..3c79dc7e3fb 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -535,10 +535,9 @@ class Theme < ActiveRecord::Basewhen :extra_jsget_set_cache("#{theme_ids.join(",")}:extra_js:#{Theme.compiler_version}") dorequire_rebake =- ThemeField.where(theme_id: theme_ids, target_id: Theme.targets[:extra_js]).where(- "compiler_version <> ?",- Theme.compiler_version,- )+ ThemeField+ .where(theme_id: theme_ids, target_id: targets[:extra_js])+ .where.not(compiler_version: compiler_version)ActiveRecord::Base.transaction dorequire_rebake.each { |tf| tf.ensure_baked! }diff --git a/app/models/topic.rb b/app/models/topic.rbindex 5d0ae74db72..1e6297408c9 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -355,7 +355,7 @@ class Topic < ActiveRecord::Base)end- scope :listable_topics, -> { where("topics.archetype <> ?", Archetype.private_message) }+ scope :listable_topics, -> { where.not(topics: { archetype: Archetype.private_message }) }scope :by_newest, -> { order("topics.created_at desc, topics.id desc") }@@ -1407,7 +1407,7 @@ class Topic < ActiveRecord::Baseprevious_banner = Topic.where(archetype: Archetype.banner).firstprevious_banner.remove_banner!(user) if previous_banner.present?- UserProfile.where("dismissed_banner_key IS NOT NULL").update_all(dismissed_banner_key: nil)+ UserProfile.where.not(dismissed_banner_key: nil).update_all(dismissed_banner_key: nil)self.archetype = Archetype.bannerself.bannered_until = bannered_untildiff --git a/app/models/trust_level3_requirements.rb b/app/models/trust_level3_requirements.rbindex 02960f833d8..54370441a0e 100644--- a/app/models/trust_level3_requirements.rb+++ b/app/models/trust_level3_requirements.rb@@ -130,7 +130,7 @@ class TrustLevel3RequirementsTopicViewItem.where(user_id: @user.id).joins(:topic)- .where("topics.archetype <> ?", Archetype.private_message)+ .where.not(topics: { archetype: Archetype.private_message }).select("topic_id")end@@ -214,7 +214,7 @@ class TrustLevel3Requirements.where(user_id: @user.id, action_type: UserAction::LIKE).where("user_actions.created_at > ?", time_period.days.ago).joins(:target_topic)- .where("topics.archetype <> ?", Archetype.private_message)+ .where.not(topics: { archetype: Archetype.private_message }).countend@@ -227,7 +227,7 @@ class TrustLevel3Requirements.where(user_id: @user.id, action_type: UserAction::WAS_LIKED).where("user_actions.created_at > ?", time_period.days.ago).joins(:target_topic)- .where("topics.archetype <> ?", Archetype.private_message)+ .where.not(topics: { archetype: Archetype.private_message })enddef num_likes_receiveddiff --git a/app/models/user_search.rb b/app/models/user_search.rbindex c91ee9be627..778cfafa2a3 100644--- a/app/models/user_search.rb+++ b/app/models/user_search.rb@@ -88,7 +88,7 @@ class UserSearchPost.types[:regular],)- in_topic = in_topic.where("users.id <> ?", @searching_user.id) if @searching_user.present?+ in_topic = in_topic.where.not(users: { id: @searching_user.id }) if @searching_user.present?if @prioritized_user_idin_topic =@@ -149,7 +149,7 @@ class UserSearchSQLif @searching_user.present?- in_category = in_category.where("users.id <> ?", @searching_user.id)+ in_category = in_category.where.not(users: { id: @searching_user.id })endin_categorydiff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex 74d721d9011..ee8d13527b5 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -1037,7 +1037,7 @@ class PostAlerternotify = notify.where(staged: false).staff if post.topic.private_message?exclude_user_ids = notified.map(&:id)- notify = notify.where("users.id NOT IN (?)", exclude_user_ids) if exclude_user_ids.present?+ notify = notify.where.not(id: exclude_user_ids) if exclude_user_ids.present?DiscourseEvent.trigger(:before_create_notifications_for_users, notify, post)diff --git a/app/services/user_destroyer.rb b/app/services/user_destroyer.rbindex 7cac0544b07..39fc1431620 100644--- a/app/services/user_destroyer.rb+++ b/app/services/user_destroyer.rb@@ -31,7 +31,7 @@ class UserDestroyerDraft.where(user_id: user.id).delete_allReviewable.where(created_by_id: user.id).delete_all- category_topic_ids = Category.where("topic_id IS NOT NULL").pluck(:topic_id)+ category_topic_ids = Category.where.not(topic_id: nil).pluck(:topic_id)if opts[:delete_posts]DiscoursePluginRegistry.user_destroyer_on_content_deletion_callbacks.each do |cb|diff --git a/lib/admin_user_index_query.rb b/lib/admin_user_index_query.rbindex cfac4052980..4b30c2c6ea3 100644--- a/lib/admin_user_index_query.rb+++ b/lib/admin_user_index_query.rb@@ -117,7 +117,7 @@ class AdminUserIndexQueryenddef filter_exclude- @query.where("users.id != ?", params[:exclude]) if params[:exclude].present?+ @query.where.not(id: params[:exclude]) if params[:exclude].present?enddef append(active_relation)diff --git a/lib/backup_restore/uploads_restorer.rb b/lib/backup_restore/uploads_restorer.rbindex 8b6c13e17d1..587cdb7099d 100644--- a/lib/backup_restore/uploads_restorer.rb+++ b/lib/backup_restore/uploads_restorer.rb@@ -155,7 +155,7 @@ module BackupRestoreSiteIconManager.ensure_optimized!User- .where("uploaded_avatar_id IS NOT NULL")+ .where.not(uploaded_avatar_id: nil).find_each do |user|Jobs.enqueue(:create_avatar_thumbnails, upload_id: user.uploaded_avatar_id)enddiff --git a/lib/discourse_dev/reviewable.rb b/lib/discourse_dev/reviewable.rbindex 9e0b795d1ef..ee4b08a30cb 100644--- a/lib/discourse_dev/reviewable.rb+++ b/lib/discourse_dev/reviewable.rb@@ -33,12 +33,7 @@ module DiscourseDevenddef self.create_needed_topics(count)- topics =- ::Topic- .listable_topics- .where("id NOT IN (?)", ::Category.pluck(:topic_id))- .limit(count)- .to_a+ topics = ::Topic.listable_topics.where.not(id: ::Category.pluck(:topic_id)).limit(count).to_a(count - topics.size).times { topics << Topic.new.create! } if topics.size < countdiff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rbindex 84df425f681..72a2daecf02 100644--- a/lib/post_action_creator.rb+++ b/lib/post_action_creator.rb@@ -296,7 +296,7 @@ class PostActionCreator}# First try to revive a trashed record- post_action = PostAction.where(where_attrs).with_deleted.where("deleted_at IS NOT NULL").first+ post_action = PostAction.where(where_attrs).with_deleted.where.not(deleted_at: nil).firstif post_actionpost_action.recover!diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rbindex eebf2e00090..ee5371e52fb 100644--- a/lib/s3_inventory.rb+++ b/lib/s3_inventory.rb@@ -92,7 +92,7 @@ class S3Inventory.joins("LEFT JOIN #{tmp_table_name} inventory2 ON inventory2.url = #{table_name}.url",)- .where("inventory2.etag IS NOT NULL")+ .where.not(inventory2: { etag: nil }).pluck(:id)# marking as verified/not verifieddiff --git a/lib/search.rb b/lib/search.rbindex 37376149623..7210280545d 100644--- a/lib/search.rb+++ b/lib/search.rb@@ -472,7 +472,7 @@ class Searchadvanced_filter(/\Ain:first|^f\z/i) { |posts| posts.where("posts.post_number = 1") }- advanced_filter(/\Ain:pinned\z/i) { |posts| posts.where("topics.pinned_at IS NOT NULL") }+ advanced_filter(/\Ain:pinned\z/i) { |posts| posts.where.not(topics: { pinned_at: nil }) }advanced_filter(/\Ain:wiki\z/i) { |posts, match| posts.where(wiki: true) }@@ -570,7 +570,7 @@ class Searchendend- advanced_filter(/\Awith:images\z/i) { |posts| posts.where("posts.image_upload_id IS NOT NULL") }+ advanced_filter(/\Awith:images\z/i) { |posts| posts.where.not(posts: { image_upload_id: nil }) }advanced_filter(/\Acategor(?:y|ies):(.+)\z/i) do |posts, terms|category_ids = []@@ -866,9 +866,11 @@ class Searchendelsif @order == :read && @guardian.userposts =- posts.joins(- "JOIN topic_users tu ON tu.topic_id = posts.topic_id AND tu.user_id = #{@guardian.user.id.to_i}",- ).where("tu.last_visited_at IS NOT NULL")+ posts+ .joins(+ "JOIN topic_users tu ON tu.topic_id = posts.topic_id AND tu.user_id = #{@guardian.user.id.to_i}",+ )+ .where.not(tu: { last_visited_at: nil })if aggregate_searchposts = posts.order("MAX(tu.last_visited_at) DESC")diff --git a/lib/suggested_topics_builder.rb b/lib/suggested_topics_builder.rbindex 57bcdfc42a1..d3abda4e3be 100644--- a/lib/suggested_topics_builder.rb+++ b/lib/suggested_topics_builder.rb@@ -15,7 +15,7 @@ class SuggestedTopicsBuilderreturn unless results# Only add results if we don't have those topic ids already- results = results.where("topics.id NOT IN (?)", @excluded_topic_ids).where(visible: true)+ results = results.where.not(topics: { id: @excluded_topic_ids }).where(visible: true)# If limit suggested to category is enabled, restrict to that categoryif @category_id && SiteSetting.limit_suggested_to_category?diff --git a/lib/tasks/topics.rake b/lib/tasks/topics.rakeindex 8629f5b28ac..d833dfd7b37 100644--- a/lib/tasks/topics.rake+++ b/lib/tasks/topics.rake@@ -71,7 +71,7 @@ endtask "topics:watch_all_replied_topics" => :environment doputs "Setting all topics to Watching on which a user has posted at least once..."- topics = Topic.where("archetype != ?", Archetype.private_message)+ topics = Topic.where.not(archetype: Archetype.private_message)total = topics.countcount = 0diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rakeindex c192c1f5629..04341ca6a06 100644--- a/lib/tasks/uploads.rake+++ b/lib/tasks/uploads.rake@@ -313,7 +313,7 @@ def regenerate_missing_optimized[default_scope.where("optimized_images.upload_id IN (?)", avatar_upload_ids),default_scope- .where("optimized_images.upload_id NOT IN (?)", avatar_upload_ids)+ .where.not(upload_id: avatar_upload_ids).where("LENGTH(COALESCE(url, '')) > 0").where("width > 0 AND height > 0"),].each do |scope|diff --git a/lib/topic_query.rb b/lib/topic_query.rbindex d9ec5384169..a62e6f63ad9 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -166,7 +166,7 @@ class TopicQueryAND gu.user_id = #{@user.id.to_i}",)- .where("gu.group_id IS NOT NULL")+ .where.not(gu: { group_id: nil }).pluck(:group_id)target_group_ids = topic.topic_allowed_groups.pluck(:group_id)@@ -327,7 +327,7 @@ class TopicQuerydef list_readcreate_list(:read, unordered: true) do |topics|- topics.where("tu.last_visited_at IS NOT NULL").order("tu.last_visited_at DESC")+ topics.where.not(tu: { last_visited_at: nil }).order("tu.last_visited_at DESC")endend@@ -701,7 +701,7 @@ class TopicQuery)end- result.where("topics.category_id != ?", drafts_category_id)+ result.where.not(topics: { category_id: drafts_category_id })enddef apply_ordering(result, options = {})@@ -1025,7 +1025,7 @@ class TopicQuerycategory_ids = SiteSetting.default_categories_muted.split("|").map(&:to_i)category_ids -= [category_id] if category_id.present? && category_ids.include?(category_id)- list = list.where("categories.id NOT IN (?)", category_ids) if category_ids.present?+ list = list.where.not(categories: { id: category_ids }) if category_ids.present?endlist@@ -1180,16 +1180,17 @@ class TopicQueryif user_ids.present? && group_ids.present?messages.where("ta2.topic_id IS NOT NULL OR tg2.topic_id IS NOT NULL")elsif user_ids.present?- messages.where("ta2.topic_id IS NOT NULL")+ messages.where.not(ta2: { topic_id: nil })elsif group_ids.present?- messages.where("tg2.topic_id IS NOT NULL")+ messages.where.not(tg2: { topic_id: nil })endenddef messages_for_groups_or_user(group_ids)if group_ids.present?- base_messages.joins(- "+ base_messages+ .joins(+ "LEFT JOIN (SELECT * FROM topic_allowed_groups _tgLEFT JOIN group_users gu@@ -1198,20 +1199,23 @@ class TopicQueryWHERE #{DB.sql_fragment("gu.group_id IN (?)", group_ids)}) tg ON topics.id = tg.topic_id",- ).where("tg.topic_id IS NOT NULL")+ )+ .where.not(tg: { topic_id: nil })elsemessages_for_userendenddef messages_for_user- base_messages.joins(- "+ base_messages+ .joins(+ "LEFT JOIN topic_allowed_users taON topics.id = ta.topic_idAND ta.user_id = #{@user.id.to_i}",- ).where("ta.topic_id IS NOT NULL")+ )+ .where.not(ta: { topic_id: nil })enddef base_messages@@ -1232,8 +1236,7 @@ class TopicQueryelseexcluded_topic_ids += Category.topic_ids.to_aend- result =- result.where("topics.id NOT IN (?)", excluded_topic_ids) unless excluded_topic_ids.empty?+ result = result.where.not(topics: { id: excluded_topic_ids }) unless excluded_topic_ids.empty?result = remove_muted(result, @user, @options)diff --git a/lib/topic_query/private_message_lists.rb b/lib/topic_query/private_message_lists.rbindex 95d62fffb29..c07bdbb7a8c 100644--- a/lib/topic_query/private_message_lists.rb+++ b/lib/topic_query/private_message_lists.rb@@ -106,7 +106,7 @@ class TopicQuerylist = user_personal_private_messages(user)list = list.where("topics.subtype = ?", TopicSubtype.moderator_warning)# Exclude official warnings that the user created, instead of received- list = list.where("topics.user_id <> ?", user.id)+ list = list.where.not(topics: { user: })create_list(:private_messages, {}, list)enddiff --git a/lib/topic_view.rb b/lib/topic_view.rbindex 7c8c82dc1f2..d19001c47d5 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -485,7 +485,7 @@ class TopicViewdef has_deleted?@predelete_filtered_posts.with_deleted- .where("posts.deleted_at IS NOT NULL")+ .where.not(deleted_at: nil).where("posts.post_number > 1").exists?end@@ -972,7 +972,7 @@ class TopicViewdef unfiltered_postsresult = filter_post_types(@topic.posts)result = result.with_deleted if @guardian.can_see_deleted_posts?(@topic.category)- result = result.where("user_id IS NOT NULL") if @exclude_deleted_users+ result = result.where.not(user_id: nil) if @exclude_deleted_usersresult = result.where(hidden: false) if @exclude_hiddenresultenddiff --git a/lib/topics_filter.rb b/lib/topics_filter.rbindex d55eb27548d..7a52bd51899 100644--- a/lib/topics_filter.rb+++ b/lib/topics_filter.rb@@ -140,7 +140,7 @@ class TopicsFiltercategory = category_id.present? ? Category.find_by(id: category_id) : nilif @guardian.can_see_deleted_topics?(category)- @scope = @scope.unscope(where: :deleted_at).where("topics.deleted_at IS NOT NULL")+ @scope = @scope.unscope(where: :deleted_at).where.not(topics: { deleted_at: nil })endwhen "public"@scope = @scope.joins(:category).where("NOT categories.read_restricted")@@ -943,7 +943,7 @@ class TopicsFilterscope: -> doif @guardian.authenticated?ensure_topic_users_reference!- @scope.where("tu.last_visited_at IS NOT NULL")+ @scope.where.not(tu: { last_visited_at: nil })else# make sure this works for anon (particularly selection)@scope.joins("LEFT JOIN topic_users tu ON 1 = 0")diff --git a/lib/validators/unique_among_validator.rb b/lib/validators/unique_among_validator.rbindex 85d91b66241..99e79d1d4a4 100644--- a/lib/validators/unique_among_validator.rb+++ b/lib/validators/unique_among_validator.rb@@ -15,7 +15,7 @@ class UniqueAmongValidator < ActiveRecord::Validations::UniquenessValidatorif new_errors.size - old_errors.size != 0# now look only in the collection we care about.dupes = options[:collection].call(record).where("lower(#{attribute}) = ?", value.downcase)- dupes = dupes.where("id != ?", record.id) if record.persisted?+ dupes = dupes.where.not(id: record.id) if record.persisted?# pop off the error, if it was a false positiveif !dupes.exists?diff --git a/plugins/automation/lib/discourse_automation/scripts/group_category_notification_default.rb b/plugins/automation/lib/discourse_automation/scripts/group_category_notification_default.rbindex 0976cef32e3..1424b2e2fc2 100644--- a/plugins/automation/lib/discourse_automation/scripts/group_category_notification_default.rb+++ b/plugins/automation/lib/discourse_automation/scripts/group_category_notification_default.rb@@ -37,9 +37,7 @@ DiscourseAutomation::Scriptable.add(category_users = []existing_users =- CategoryUser.where(category_id: category_id, user_id: user_ids).where(- "notification_level IS NOT NULL",- )+ CategoryUser.where(category_id:, user_id: user_ids).where.not(notification_level: nil)skip_user_ids = existing_users.pluck(:user_id)batch.each do |group_user|diff --git a/plugins/chat/app/models/chat/channel.rb b/plugins/chat/app/models/chat/channel.rbindex 1078acf4066..75a556e011b 100644--- a/plugins/chat/app/models/chat/channel.rb+++ b/plugins/chat/app/models/chat/channel.rb@@ -57,9 +57,9 @@ module Chatendscope :public_channels,-> do- with_categories.where(chatable_type: public_channel_chatable_types).where(- "categories.id IS NOT NULL",- )+ with_categories+ .where(chatable_type: public_channel_chatable_types)+ .where.not(categories: { id: nil })enddelegate :empty?, to: :chat_messages, prefix: truediff --git a/plugins/chat/lib/chat/post_notification_handler.rb b/plugins/chat/lib/chat/post_notification_handler.rbindex 449d6c27a22..8de6677e2c2 100644--- a/plugins/chat/lib/chat/post_notification_handler.rb+++ b/plugins/chat/lib/chat/post_notification_handler.rb@@ -19,9 +19,7 @@ module Chatreturn false if post.topic.private_message?quoted_users = extract_quoted_users(post)- if @notified_users.present?- quoted_users = quoted_users.where("users.id NOT IN (?)", @notified_users)- end+ quoted_users = quoted_users.where.not(id: @notified_users) if @notified_users.present?opts = { user_id: post.user.id, display_username: post.user.username }quoted_users.each do |user|diff --git a/plugins/discourse-ai/app/jobs/regular/localize_categories.rb b/plugins/discourse-ai/app/jobs/regular/localize_categories.rbindex ab143ea278f..8136eb62e62 100644--- a/plugins/discourse-ai/app/jobs/regular/localize_categories.rb+++ b/plugins/discourse-ai/app/jobs/regular/localize_categories.rb@@ -15,7 +15,7 @@ module Jobscategories =DiscourseAi::Translation::CategoryCandidates.get- .where("locale IS NOT NULL")+ .where.not(locale: nil).order(:id).limit(limit)return if categories.empty?diff --git a/plugins/discourse-ai/lib/automation/report_context_generator.rb b/plugins/discourse-ai/lib/automation/report_context_generator.rbindex fb6c8ce5cd4..6bf4a0419b1 100644--- a/plugins/discourse-ai/lib/automation/report_context_generator.rb+++ b/plugins/discourse-ai/lib/automation/report_context_generator.rb@@ -53,9 +53,10 @@ module DiscourseAiif exclude_tags.present?exclude_tag_ids = Tag.where_name(exclude_tags).select(:id)@posts =- @posts.where(- "topics.id NOT IN (?)",- TopicTag.where(tag_id: exclude_tag_ids).select(:topic_id),+ @posts.where.not(+ topics: {+ id: TopicTag.where(tag_id: exclude_tag_ids).select(:topic_id),+ },)enddiff --git a/plugins/discourse-ai/lib/configuration/llm_enumerator.rb b/plugins/discourse-ai/lib/configuration/llm_enumerator.rbindex cd2c33d54ea..dcf10a16876 100644--- a/plugins/discourse-ai/lib/configuration/llm_enumerator.rb+++ b/plugins/discourse-ai/lib/configuration/llm_enumerator.rb@@ -17,7 +17,7 @@ module DiscourseAi# this is unconditional, so it is clear that we always signal configurationAiPersona- .where("default_llm_id IS NOT NULL")+ .where.not(default_llm_id: nil).pluck(:default_llm_id, :name, :id).each { |llm_id, name, id| rval[llm_id] << { type: :ai_persona, name: name, id: id } }diff --git a/plugins/discourse-ai/lib/inferred_concepts/finder.rb b/plugins/discourse-ai/lib/inferred_concepts/finder.rbindex 9e1466f5a30..a74612caab8 100644--- a/plugins/discourse-ai/lib/inferred_concepts/finder.rb+++ b/plugins/discourse-ai/lib/inferred_concepts/finder.rb@@ -69,7 +69,7 @@ module DiscourseAi)# Apply additional filters- query = query.where("topics.id NOT IN (?)", exclude_topic_ids) if exclude_topic_ids.present?+ query = query.where.not(id: exclude_topic_ids) if exclude_topic_ids.present?query = query.where("topics.category_id IN (?)", category_ids) if category_ids.present?query = query.where("topics.created_at >= ?", created_after) if created_after.present?@@ -118,7 +118,7 @@ module DiscourseAiquery = query.where("posts.post_number > 1") if exclude_first_posts# Apply additional filters- query = query.where("posts.id NOT IN (?)", exclude_post_ids) if exclude_post_ids.present?+ query = query.where.not(id: exclude_post_ids) if exclude_post_ids.present?query = query.where("posts.created_at >= ?", created_after) if created_after.present?# Filter by category if specifieddiff --git a/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake b/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rakeindex aa866f99231..c9a62d65a81 100644--- a/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake+++ b/plugins/discourse-ai/lib/tasks/modules/toxicity/calibration.rake@@ -17,7 +17,7 @@ task "ai:toxicity:calibration_stats", [:set_size] => [:environment] do |_, args|.where("post_actions.user_id > 0").includes(:post, :user).where(user: { admin: false, moderator: false })- .where("posts.raw IS NOT NULL")+ .where.not(posts: { raw: nil }).order(created_at: :desc).limit(args[:set_size]).pluck(:raw)@@ -29,7 +29,7 @@ task "ai:toxicity:calibration_stats", [:set_size] => [:environment] do |_, args|.where("post_actions.user_id > 0").includes(:post, :user).where(user: { admin: false, moderator: false })- .where("posts.raw IS NOT NULL")+ .where.not(posts: { raw: nil }).order(created_at: :desc).limit(args[:set_size]).pluck(:raw)diff --git a/plugins/discourse-ai/lib/translation/category_candidates.rb b/plugins/discourse-ai/lib/translation/category_candidates.rbindex b403de04c65..af1fc7bbda5 100644--- a/plugins/discourse-ai/lib/translation/category_candidates.rb+++ b/plugins/discourse-ai/lib/translation/category_candidates.rb@@ -19,7 +19,7 @@ module DiscourseAibase_locale = "#{locale.split("_").first}%"sql = <<~SQLWITH eligible_categories AS (- #{get.where("categories.locale IS NOT NULL").to_sql}+ #{get.where.not(categories: { locale: nil }).to_sql}),total_count AS (SELECT COUNT(*) AS count FROM eligible_categoriesdiff --git a/plugins/discourse-ai/lib/translation/post_candidates.rb b/plugins/discourse-ai/lib/translation/post_candidates.rbindex d2f62425304..2c9b32d66ba 100644--- a/plugins/discourse-ai/lib/translation/post_candidates.rb+++ b/plugins/discourse-ai/lib/translation/post_candidates.rb@@ -93,7 +93,7 @@ module DiscourseAiFROM (VALUES #{values_rows}) AS t(localestr)),eligible_posts AS (- #{get.where("posts.locale IS NOT NULL").to_sql}+ #{get.where.not(posts: { locale: nil }).to_sql}),total_count AS (SELECT COUNT(*)::bigint AS count FROM eligible_postsdiff --git a/plugins/discourse-ai/lib/translation/topic_candidates.rb b/plugins/discourse-ai/lib/translation/topic_candidates.rbindex 967055f831f..a71c67cebcb 100644--- a/plugins/discourse-ai/lib/translation/topic_candidates.rb+++ b/plugins/discourse-ai/lib/translation/topic_candidates.rb@@ -39,7 +39,7 @@ module DiscourseAisql = <<~SQLWITH eligible_topics AS (- #{get.where("topics.locale IS NOT NULL").to_sql}+ #{get.where.not(topics: { locale: nil }).to_sql}),total_count AS (SELECT COUNT(*) AS count FROM eligible_topicsdiff --git a/plugins/discourse-ai/lib/utils/research/filter.rb b/plugins/discourse-ai/lib/utils/research/filter.rbindex eede86004a7..087077d7c5c 100644--- a/plugins/discourse-ai/lib/utils/research/filter.rb+++ b/plugins/discourse-ai/lib/utils/research/filter.rb@@ -179,9 +179,9 @@ module DiscourseAi"a.assigned_to_id IS NULL",)elsif name == "*"- relation.joins("JOIN assignments a ON a.topic_id = topics.id AND a.active").where(- "a.assigned_to_id IS NOT NULL",- )+ relation+ .joins("JOIN assignments a ON a.topic_id = topics.id AND a.active")+ .where.not(a: { assigned_to_id: nil })elseusernames = name.split(",").map(&:strip).map(&:downcase)relation.joins("JOIN assignments a ON a.topic_id = topics.id AND a.active").where(diff --git a/plugins/discourse-ai/spec/configuration/feature_spec.rb b/plugins/discourse-ai/spec/configuration/feature_spec.rbindex c01cdf39916..ba402b78598 100644--- a/plugins/discourse-ai/spec/configuration/feature_spec.rb+++ b/plugins/discourse-ai/spec/configuration/feature_spec.rb@@ -168,7 +168,7 @@ RSpec.describe DiscourseAi::Configuration::Feature doit "returns only personas with at least one bot permission enabled" doexpected_ids = [chat_persona.id, dm_persona.id, topic_persona.id, pm_persona.id]- AiPersona.where("id not in (:ids)", ids: expected_ids).update_all(enabled: false)+ AiPersona.where.not(id: expected_ids).update_all(enabled: false)expect(bot_feature.persona_ids).to match_array(expected_ids)expect(bot_feature.persona_ids).not_to include(inactive_persona.id)enddiff --git a/plugins/discourse-ai/spec/plugin_helper.rb b/plugins/discourse-ai/spec/plugin_helper.rbindex 4e2a58a7fd2..8ccff6faf1b 100644--- a/plugins/discourse-ai/spec/plugin_helper.rb+++ b/plugins/discourse-ai/spec/plugin_helper.rb@@ -3,7 +3,7 @@module DiscourseAi::ChatBotHelperdef toggle_enabled_bots(bots: [])models = LlmModel.all- models = models.where("id not in (?)", bots.map(&:id)) if bots.present?+ models = models.where.not(id: bots.map(&:id)) if bots.present?models.update_all(enabled_chat_bot: false)bots.each { |b| b.update!(enabled_chat_bot: true) }diff --git a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rbindex 5b41a45292e..ddd50e49242 100644--- a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb+++ b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb@@ -232,7 +232,7 @@ module DiscourseAssigndef recent_assigneesUser- .where("users.id <> ?", current_user.id)+ .where.not(id: current_user.id).joins(<<~SQL)JOIN(SELECT assigned_to_id user_id, MAX(created_at) last_assigneddiff --git a/plugins/discourse-assign/plugin.rb b/plugins/discourse-assign/plugin.rbindex 05be3c6bc7c..23b97dab801 100644--- a/plugins/discourse-assign/plugin.rb+++ b/plugins/discourse-assign/plugin.rb@@ -315,9 +315,9 @@ after_initialize doif name == "*"next(- results.joins("JOIN assignments a ON a.topic_id = topics.id AND active").where(- "a.assigned_to_id IS NOT NULL",- )+ results+ .joins("JOIN assignments a ON a.topic_id = topics.id AND active")+ .where.not(a: { assigned_to_id: nil }))enddiff --git a/plugins/discourse-calendar/app/models/discourse_post_event/invitee.rb b/plugins/discourse-calendar/app/models/discourse_post_event/invitee.rbindex d2811edcefd..92b298a06ff 100644--- a/plugins/discourse-calendar/app/models/discourse_post_event/invitee.rb+++ b/plugins/discourse-calendar/app/models/discourse_post_event/invitee.rb@@ -9,7 +9,7 @@ module DiscoursePostEventbelongs_to :event, foreign_key: :post_idbelongs_to :user- default_scope { joins(:user).includes(:user).where("users.id IS NOT NULL") }+ default_scope { joins(:user).includes(:user).where.not(users: { id: nil }) }scope :with_status, ->(status) { where(status: Invitee.statuses[status]) }after_commit :sync_chat_channel_membersdiff --git a/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb b/plugins/discourse-post-voting/spec/lib/topic_view_spec.rbindex ab41f217a99..dd317d5f70f 100644--- a/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb+++ b/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb@@ -179,7 +179,7 @@ describe TopicView doTopicView.new(topic.id,user,- post_number: topic.posts.where("deleted_at IS NOT NULL").pick(:post_number),+ post_number: topic.posts.where.not(deleted_at: nil).pick(:post_number),)expect(near_view.desired_post.id).to eq(post.id)diff --git a/plugins/discourse-reactions/app/controllers/discourse_reactions/custom_reactions_controller.rb b/plugins/discourse-reactions/app/controllers/discourse_reactions/custom_reactions_controller.rbindex 05a2725aece..289069adfaf 100644--- a/plugins/discourse-reactions/app/controllers/discourse_reactions/custom_reactions_controller.rb+++ b/plugins/discourse-reactions/app/controllers/discourse_reactions/custom_reactions_controller.rb@@ -67,7 +67,7 @@ class DiscourseReactions::CustomReactionsController < ApplicationController.joins("LEFT JOIN categories c ON c.id = t.category_id").includes(:user, :post, :reaction).where(user_id: user.id)- .where("discourse_reactions_reactions.reaction_users_count IS NOT NULL")+ .where.not(discourse_reactions_reactions: { reaction_users_count: nil })reaction_users = secure_reaction_users!(reaction_users)@@ -101,7 +101,7 @@ class DiscourseReactions::CustomReactionsController < ApplicationControllerDiscourseReactions::ReactionUser.joins(:reaction).where(post_id: post_ids)- .where("discourse_reactions_reactions.reaction_users_count IS NOT NULL")+ .where.not(discourse_reactions_reactions: { reaction_users_count: nil })# Guarantee backwards compatibility if someone was calling this endpoint with the old param.# TODO(roman): Remove after the 2.9 release.@@ -186,9 +186,10 @@ class DiscourseReactions::CustomReactionsController < ApplicationController.joins("LEFT JOIN discourse_reactions_reactions ON discourse_reactions_reactions.id = discourse_reactions_reaction_users.reaction_id",)- .where(- "discourse_reactions_reactions.reaction_value NOT IN (:valid_reactions)",- valid_reactions: DiscourseReactions::Reaction.valid_reactions.to_a,+ .where.not(+ discourse_reactions_reactions: {+ reaction_value: DiscourseReactions::Reaction.valid_reactions.to_a,+ },)likes = likes.where.not(id: historical_reaction_likes.select(:id))diff --git a/plugins/discourse-solved/lib/discourse_solved/register_filters.rb b/plugins/discourse-solved/lib/discourse_solved/register_filters.rbindex ed0163e3df5..63eb5dce6ae 100644--- a/plugins/discourse-solved/lib/discourse_solved/register_filters.rb+++ b/plugins/discourse-solved/lib/discourse_solved/register_filters.rb@@ -4,9 +4,11 @@ module DiscourseSolvedclass RegisterFiltersdef self.register(plugin)solved_callback = ->(scope) do- scope.joins(- "INNER JOIN discourse_solved_solved_topics ON discourse_solved_solved_topics.topic_id = topics.id",- ).where("topics.archetype <> ?", Archetype.private_message)+ scope+ .joins(+ "INNER JOIN discourse_solved_solved_topics ON discourse_solved_solved_topics.topic_id = topics.id",+ )+ .where.not(topics: { archetype: Archetype.private_message })endunsolved_callback = ->(scope) do@@ -38,7 +40,7 @@ module DiscourseSolvedSQLend- scope.where("topics.archetype <> ?", Archetype.private_message)+ scope.where.not(topics: { archetype: Archetype.private_message })endplugin.register_custom_filter_by_status("solved", &solved_callback)diff --git a/plugins/discourse-solved/plugin.rb b/plugins/discourse-solved/plugin.rbindex 4c256b5bb98..c1b57a9eae2 100644--- a/plugins/discourse-solved/plugin.rb+++ b/plugins/discourse-solved/plugin.rb@@ -205,10 +205,9 @@ after_initialize doreport.data = []accepted_solutions =- DiscourseSolved::SolvedTopic.joins(:topic).where(- "topics.archetype <> ?",- Archetype.private_message,- )+ DiscourseSolved::SolvedTopic+ .joins(:topic)+ .where.not(topics: { archetype: Archetype.private_message })category_id, include_subcategories = report.add_category_filterif category_iddiff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rbindex a1a1aadda28..4656671bee2 100644--- a/script/bulk_import/base.rb+++ b/script/bulk_import/base.rb@@ -258,7 +258,7 @@ class BulkImport::Base@last_upload_id = last_id(Upload)@user_ids_by_username_lower = User.unscoped.pluck(:id, :username_lower).to_h@usernames_by_id = User.unscoped.pluck(:id, :username).to_h- @user_full_names_by_id = User.unscoped.where("name IS NOT NULL").pluck(:id, :name).to_h+ @user_full_names_by_id = User.unscoped.where.not(name: nil).pluck(:id, :name).to_hputs "Loading categories indexes..."@last_category_id = last_id(Category)diff --git a/spec/requests/post_action_users_controller_spec.rb b/spec/requests/post_action_users_controller_spec.rbindex fc3f28683dc..72454fab2c3 100644--- a/spec/requests/post_action_users_controller_spec.rb+++ b/spec/requests/post_action_users_controller_spec.rb@@ -153,7 +153,7 @@ RSpec.describe PostActionUsersController do.new.register_modifier(:post_action_users_list) do |query, modifier_post|expect(modifier_post.id).to eq(post.id)- query.where("post_actions.id NOT IN (?)", excluded_post_action_ids)+ query.where.not(post_actions: { id: excluded_post_action_ids })endget "/post_action_users.json",diff --git a/spec/services/sidebar_site_settings_backfiller_spec.rb b/spec/services/sidebar_site_settings_backfiller_spec.rbindex 439ef1ed332..d4351b9bb38 100644--- a/spec/services/sidebar_site_settings_backfiller_spec.rb+++ b/spec/services/sidebar_site_settings_backfiller_spec.rb@@ -49,7 +49,7 @@ RSpec.describe SidebarSiteSettingsBackfiller dobefore do# Clean up random users created as part of fabrication to make assertions easier to understand.- User.real.where("id NOT IN (?)", [user.id, user2.id, user3.id, staged_user.id]).delete_all+ User.real.where.not(id: [user.id, user2.id, user3.id, staged_user.id]).delete_allendit "raises an error when class is initialized with invalid setting name" do