Fix Rails/WhereRange
cop (#30343)
This commit is contained in:
parent
70608f824e
commit
def6b686ff
10 changed files with 15 additions and 15 deletions
|
@ -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
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Vacuum::StatusesVacuum
|
||||||
def statuses_scope
|
def statuses_scope
|
||||||
Status.unscoped.kept
|
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 })
|
||||||
end
|
end
|
||||||
|
|
||||||
def retention_period_as_id
|
def retention_period_as_id
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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 }
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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!
|
||||||
|
|
|
@ -20,7 +20,7 @@ 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 publish_scheduled_announcements!
|
def publish_scheduled_announcements!
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Scheduler::UserCleanupScheduler
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_discarded_statuses!
|
def clean_discarded_statuses!
|
||||||
Status.unscoped.discarded.where('deleted_at <= ?', DISCARDED_STATUSES_MAX_AGE_DAYS.days.ago).find_in_batches do |statuses|
|
Status.unscoped.discarded.where(deleted_at: ..DISCARDED_STATUSES_MAX_AGE_DAYS.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
|
||||||
|
|
|
@ -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?
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue