Fix rubocop

This commit is contained in:
KMY 2024-07-05 07:34:53 +09:00
parent 6b59ce6985
commit efa0c376bc
23 changed files with 32 additions and 32 deletions

View file

@ -44,7 +44,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
end end
def build_resource(hash = nil) def build_resource(hash = nil)
super(hash) super
resource.locale = I18n.locale resource.locale = I18n.locale
resource.invite_code = @invite&.code if resource.invite_code.blank? resource.invite_code = @invite&.code if resource.invite_code.blank?

View file

@ -26,7 +26,7 @@ module RegistrationLimitationHelper
end end
def today_increase_user_count_value def today_increase_user_count_value
User.confirmed.enabled.where('users.created_at >= ?', Time.now.utc.beginning_of_day).joins(:account).merge(Account.without_suspended).count User.confirmed.enabled.where(users: { created_at: Time.now.utc.beginning_of_day.. }).joins(:account).merge(Account.without_suspended).count
end end
def registrations_in_time? def registrations_in_time?

View file

@ -33,6 +33,6 @@ class ActivityPub::Serializer < ActiveModel::Serializer
adapter_options[:named_contexts].merge!(_named_contexts) adapter_options[:named_contexts].merge!(_named_contexts)
adapter_options[:context_extensions].merge!(_context_extensions) adapter_options[:context_extensions].merge!(_context_extensions)
end end
super(adapter_options, options, adapter_instance) super
end end
end end

View file

@ -5,7 +5,7 @@ require_relative 'shared_timed_stack'
class ConnectionPool::SharedConnectionPool < ConnectionPool class ConnectionPool::SharedConnectionPool < ConnectionPool
def initialize(options = {}, &block) def initialize(options = {}, &block)
super(options, &block) super
@available = ConnectionPool::SharedTimedStack.new(@size, &block) @available = ConnectionPool::SharedTimedStack.new(@size, &block)
end end

View file

@ -28,8 +28,8 @@ class Importer::PublicStatusesIndexImporter < Importer::BaseImporter
def scope def scope
to_index = Status.indexable.reorder(nil) to_index = Status.indexable.reorder(nil)
to_index = to_index.where('statuses.created_at >= ?', @from) if @from.present? to_index = to_index.where(statuses: { created_at: @from.. }) if @from.present?
to_index = to_index.where('statuses.created_at < ?', @to) if @to.present? to_index = to_index.where(statuses: { created_at: ...@to }) if @to.present?
to_index to_index
end end
end end

View file

@ -17,8 +17,8 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
bulk = ActiveRecord::Base.connection_pool.with_connection do bulk = ActiveRecord::Base.connection_pool.with_connection do
to_index = index.adapter.default_scope.where(id: status_ids) to_index = index.adapter.default_scope.where(id: status_ids)
to_index = to_index.where('created_at >= ?', @from) if @from.present? to_index = to_index.where(created_at: @from..) if @from.present?
to_index = to_index.where('created_at < ?', @to) if @to.present? to_index = to_index.where(created_at: ...@to) if @to.present?
crutches = Chewy::Index::Crutch::Crutches.new index, to_index crutches = Chewy::Index::Crutch::Crutches.new index, to_index
to_index.map do |object| to_index.map do |object|
# This is unlikely to happen, but the post may have been # This is unlikely to happen, but the post may have been

View file

@ -2,7 +2,7 @@
class RSS::Channel < RSS::Element class RSS::Channel < RSS::Element
def initialize def initialize
super() super
@root = create_element('channel') @root = create_element('channel')
end end

View file

@ -2,7 +2,7 @@
class RSS::Item < RSS::Element class RSS::Item < RSS::Element
def initialize def initialize
super() super
@root = create_element('item') @root = create_element('item')
end end

View file

@ -9,10 +9,10 @@ class Vacuum::ImportsVacuum
private private
def clean_unconfirmed_imports! def clean_unconfirmed_imports!
BulkImport.state_unconfirmed.where('created_at <= ?', 10.minutes.ago).reorder(nil).in_batches.delete_all BulkImport.state_unconfirmed.where(created_at: ..10.minutes.ago).reorder(nil).in_batches.delete_all
end end
def clean_old_imports! def clean_old_imports!
BulkImport.where('created_at <= ?', 1.week.ago).reorder(nil).in_batches.delete_all BulkImport.where(created_at: ..1.week.ago).reorder(nil).in_batches.delete_all
end end
end end

View file

@ -12,6 +12,6 @@ class Vacuum::ListStatusesVacuum
private private
def vacuum_list_statuses! def vacuum_list_statuses!
ListStatus.where('created_at < ?', LIST_STATUS_LIFE_DURATION.ago).in_batches.destroy_all ListStatus.where(created_at: ...LIST_STATUS_LIFE_DURATION.ago).in_batches.destroy_all
end end
end end

View file

@ -12,7 +12,7 @@ class Vacuum::NgHistoriesVacuum
private private
def vacuum_histories! def vacuum_histories!
NgwordHistory.where('created_at < ?', HISTORY_LIFE_DURATION.ago).in_batches.destroy_all NgwordHistory.where(created_at: ...HISTORY_LIFE_DURATION.ago).in_batches.destroy_all
NgRuleHistory.where('created_at < ?', HISTORY_LIFE_DURATION.ago).in_batches.destroy_all NgRuleHistory.where(created_at: ...HISTORY_LIFE_DURATION.ago).in_batches.destroy_all
end end
end end

View file

@ -34,7 +34,7 @@ class Vacuum::StatusesVacuum
def statuses_scope def statuses_scope
scope = Status.unscoped.kept scope = Status.unscoped.kept
.joins(:account).merge(Account.remote) .joins(:account).merge(Account.remote)
.where('statuses.id < ?', retention_period_as_id) .where(statuses: { id: ...retention_period_as_id })
if Setting.delete_content_cache_without_reaction if Setting.delete_content_cache_without_reaction
scope = scope.where.not(id: favourited_statuses) scope = scope.where.not(id: favourited_statuses)

View file

@ -212,7 +212,7 @@ module Account::Interactions
return false unless local? return false unless local?
scope = followers scope = followers
scope = scope.where('follows.created_at < ?', since) if since.present? scope = scope.where(follows: { created_at: ...since }) if since.present?
scope.exists?(domain: other_domain) scope.exists?(domain: other_domain)
end end

View file

@ -23,7 +23,7 @@ module Attachmentable
included do included do
def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName
super(name, options) super
send(:"before_#{name}_validate", prepend: true) do send(:"before_#{name}_validate", prepend: true) do
attachment = send(name) attachment = send(name)

View file

@ -4,7 +4,7 @@ module Expireable
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) } scope :expired, -> { where.not(expires_at: nil).where(expires_at: ...Time.now.utc) }
def expires_in def expires_in
return @expires_in if defined?(@expires_in) return @expires_in if defined?(@expires_in)

View file

@ -24,7 +24,7 @@ class Invite < ApplicationRecord
belongs_to :user, inverse_of: :invites belongs_to :user, inverse_of: :invites
has_many :users, inverse_of: :invite, dependent: nil has_many :users, inverse_of: :invite, dependent: nil
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) } scope :available, -> { where(expires_at: nil).or(where(expires_at: Time.now.utc..)) }
validates :comment, length: { maximum: COMMENT_SIZE_LIMIT } validates :comment, length: { maximum: COMMENT_SIZE_LIMIT }

View file

@ -394,7 +394,7 @@ class Status < ApplicationRecord
end end
def add_status_referred_by_count!(diff) def add_status_referred_by_count!(diff)
update_status_stat!(status_referred_by_count: [public_send(:status_referred_by_count) + diff, 0].max) update_status_stat!(status_referred_by_count: [status_referred_by_count + diff, 0].max)
end end
def emoji_reactions_grouped_by_name(account = nil, **options) def emoji_reactions_grouped_by_name(account = nil, **options)

View file

@ -4,6 +4,6 @@ class BackupPolicy < ApplicationPolicy
MIN_AGE = 6.days MIN_AGE = 6.days
def create? def create?
user_signed_in? && current_user.backups.where('created_at >= ?', MIN_AGE.ago).count.zero? user_signed_in? && current_user.backups.where(created_at: MIN_AGE.ago..).count.zero?
end end
end end

View file

@ -16,11 +16,11 @@ class Scheduler::IpCleanupScheduler
private private
def clean_ip_columns! def clean_ip_columns!
SessionActivation.where('updated_at < ?', SESSION_RETENTION_PERIOD.ago).in_batches.destroy_all SessionActivation.where(updated_at: ...SESSION_RETENTION_PERIOD.ago).in_batches.destroy_all
SessionActivation.where('updated_at < ?', IP_RETENTION_PERIOD.ago).in_batches.update_all(ip: nil) SessionActivation.where(updated_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(ip: nil)
User.where('current_sign_in_at < ?', IP_RETENTION_PERIOD.ago).in_batches.update_all(sign_up_ip: nil) User.where(current_sign_in_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(sign_up_ip: nil)
LoginActivity.where('created_at < ?', IP_RETENTION_PERIOD.ago).in_batches.destroy_all LoginActivity.where(created_at: ...IP_RETENTION_PERIOD.ago).in_batches.destroy_all
Doorkeeper::AccessToken.where('last_used_at < ?', IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil) Doorkeeper::AccessToken.where(last_used_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil)
end end
def clean_expired_ip_blocks! def clean_expired_ip_blocks!

View file

@ -27,11 +27,11 @@ class Scheduler::ScheduledStatusesScheduler
end end
def due_statuses def due_statuses
ScheduledStatus.where('scheduled_at <= ?', Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET) ScheduledStatus.where(scheduled_at: ..(Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET))
end end
def expired_statuses def expired_statuses
ScheduledExpirationStatus.where('scheduled_at <= ?', Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET) ScheduledExpirationStatus.where(scheduled_at: ..(Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET))
end end
def publish_scheduled_announcements! def publish_scheduled_announcements!

View file

@ -22,7 +22,7 @@ class Scheduler::UserCleanupScheduler
end end
def clean_discarded_statuses! def clean_discarded_statuses!
Status.unscoped.discarded.where('deleted_at <= ?', 30.days.ago).find_in_batches do |statuses| Status.unscoped.discarded.where(deleted_at: ..30.days.ago).find_in_batches do |statuses|
RemovalWorker.push_bulk(statuses) do |status| RemovalWorker.push_bulk(statuses) do |status|
[status.id, { 'immediate' => true, 'skip_streaming' => true }] [status.id, { 'immediate' => true, 'skip_streaming' => true }]
end end

View file

@ -29,7 +29,7 @@ module Mastodon::CLI
link = options[:link] ? 'link-type ' : '' link = options[:link] ? 'link-type ' : ''
scope = PreviewCard.cached scope = PreviewCard.cached
scope = scope.where(type: :link) if options[:link] scope = scope.where(type: :link) if options[:link]
scope = scope.where('updated_at < ?', time_ago) scope = scope.where(updated_at: ...time_ago)
processed, aggregate = parallelize_with_progress(scope) do |preview_card| processed, aggregate = parallelize_with_progress(scope) do |preview_card|
next if preview_card.image.blank? next if preview_card.image.blank?

View file

@ -163,7 +163,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
def cleanable_statuses_count def cleanable_statuses_count
Status Status
.where(account_id: [account_alice, account_chris, account_erin]) # Accounts with enabled policies .where(account_id: [account_alice, account_chris, account_erin]) # Accounts with enabled policies
.where('created_at < ?', 2.weeks.ago) # Policy defaults is 2.weeks .where(created_at: ...2.weeks.ago) # Policy defaults is 2.weeks
.count .count
end end
end end