Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Jul 4, 2024
1 parent 6b59ce6 commit efa0c37
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update_resource(resource, params)
end

def build_resource(hash = nil)
super(hash)
super

resource.locale = I18n.locale
resource.invite_code = @invite&.code if resource.invite_code.blank?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/registration_limitation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def today_increase_user_count
end

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

def registrations_in_time?
Expand Down
2 changes: 1 addition & 1 deletion app/lib/activitypub/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ def serializable_hash(adapter_options = nil, options = {}, adapter_instance = se
adapter_options[:named_contexts].merge!(_named_contexts)
adapter_options[:context_extensions].merge!(_context_extensions)
end
super(adapter_options, options, adapter_instance)
super
end
end
2 changes: 1 addition & 1 deletion app/lib/connection_pool/shared_connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ConnectionPool::SharedConnectionPool < ConnectionPool
def initialize(options = {}, &block)
super(options, &block)
super

@available = ConnectionPool::SharedTimedStack.new(@size, &block)
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/importer/public_statuses_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def index

def scope
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 < ?', @to) if @to.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
end
end
4 changes: 2 additions & 2 deletions app/lib/importer/statuses_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def import!

bulk = ActiveRecord::Base.connection_pool.with_connection do
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 < ?', @to) if @to.present?
to_index = to_index.where(created_at: @from..) if @from.present?
to_index = to_index.where(created_at: ...@to) if @to.present?
crutches = Chewy::Index::Crutch::Crutches.new index, to_index
to_index.map do |object|
# This is unlikely to happen, but the post may have been
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rss/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class RSS::Channel < RSS::Element
def initialize
super()
super

@root = create_element('channel')
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rss/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class RSS::Item < RSS::Element
def initialize
super()
super

@root = create_element('item')
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/vacuum/imports_vacuum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def perform
private

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

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
2 changes: 1 addition & 1 deletion app/lib/vacuum/list_statuses_vacuum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def perform
private

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
4 changes: 2 additions & 2 deletions app/lib/vacuum/ng_histories_vacuum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def perform
private

def vacuum_histories!
NgwordHistory.where('created_at < ?', HISTORY_LIFE_DURATION.ago).in_batches.destroy_all
NgRuleHistory.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
end
end
2 changes: 1 addition & 1 deletion app/lib/vacuum/statuses_vacuum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def vacuum_statuses!
def statuses_scope
scope = Status.unscoped.kept
.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
scope = scope.where.not(id: favourited_statuses)
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/account/interactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def followed_by_domain?(other_domain, since = nil)
return false unless local?

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)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/attachmentable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Attachmentable

included do
def self.has_attached_file(name, options = {}) # rubocop:disable Naming/PredicateName
super(name, options)
super

send(:"before_#{name}_validate", prepend: true) do
attachment = send(name)
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/expireable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Expireable
extend ActiveSupport::Concern

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
return @expires_in if defined?(@expires_in)
Expand Down
2 changes: 1 addition & 1 deletion app/models/invite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Invite < ApplicationRecord
belongs_to :user, inverse_of: :invites
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 }

Expand Down
2 changes: 1 addition & 1 deletion app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def decrement_count!(key)
end

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

def emoji_reactions_grouped_by_name(account = nil, **options)
Expand Down
2 changes: 1 addition & 1 deletion app/policies/backup_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class BackupPolicy < ApplicationPolicy
MIN_AGE = 6.days

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
10 changes: 5 additions & 5 deletions app/workers/scheduler/ip_cleanup_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def perform
private

def clean_ip_columns!
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)
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
Doorkeeper::AccessToken.where('last_used_at < ?', IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil)
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)
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
Doorkeeper::AccessToken.where(last_used_at: ...IP_RETENTION_PERIOD.ago).in_batches.update_all(last_used_ip: nil)
end

def clean_expired_ip_blocks!
Expand Down
4 changes: 2 additions & 2 deletions app/workers/scheduler/scheduled_statuses_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def unpublish_expired_statuses!
end

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

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

def publish_scheduled_announcements!
Expand Down
2 changes: 1 addition & 1 deletion app/workers/scheduler/user_cleanup_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def clean_unconfirmed_accounts!
end

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|
[status.id, { 'immediate' => true, 'skip_streaming' => true }]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mastodon/cli/preview_cards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def remove
link = options[:link] ? 'link-type ' : ''
scope = PreviewCard.cached
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|
next if preview_card.image.blank?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
def cleanable_statuses_count
Status
.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
end
end
Expand Down

0 comments on commit efa0c37

Please sign in to comment.