Fix most rubocop issues (#2165)
* Run rubocop --autocorrect on app/, config/ and lib/, also manually fix some remaining style issues * Run rubocop --autocorrect-all on db/ * Run rubocop --autocorrect-all on `spec/` and fix remaining issues
This commit is contained in:
@@ -4,9 +4,8 @@ class DirectFeed < Feed
|
||||
include Redisable
|
||||
|
||||
def initialize(account)
|
||||
@type = :direct
|
||||
@id = account.id
|
||||
@account = account
|
||||
super(:direct, account.id)
|
||||
end
|
||||
|
||||
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
||||
@@ -19,10 +18,12 @@ class DirectFeed < Feed
|
||||
|
||||
private
|
||||
|
||||
def from_database(limit, max_id, since_id, min_id)
|
||||
# TODO: _min_id is not actually handled by `as_direct_timeline`
|
||||
def from_database(limit, max_id, since_id, _min_id)
|
||||
loop do
|
||||
statuses = Status.as_direct_timeline(@account, limit, max_id, since_id, min_id)
|
||||
statuses = Status.as_direct_timeline(@account, limit, max_id, since_id)
|
||||
return statuses if statuses.empty?
|
||||
|
||||
max_id = statuses.last.id
|
||||
statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) }
|
||||
return statuses unless statuses.empty?
|
||||
|
||||
@@ -338,7 +338,7 @@ class Status < ApplicationRecord
|
||||
visibilities.keys - %w(direct limited)
|
||||
end
|
||||
|
||||
def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false)
|
||||
def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil)
|
||||
# direct timeline is mix of direct message from_me and to_me.
|
||||
# 2 queries are executed with pagination.
|
||||
# constant expression using arel_table is required for partial index
|
||||
@@ -369,14 +369,9 @@ class Status < ApplicationRecord
|
||||
query_to_me = query_to_me.where('mentions.status_id > ?', since_id)
|
||||
end
|
||||
|
||||
if cache_ids
|
||||
# returns array of cache_ids object that have id and updated_at
|
||||
(query_from_me.cache_ids.to_a + query_to_me.cache_ids.to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
|
||||
else
|
||||
# returns ActiveRecord.Relation
|
||||
items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
|
||||
Status.where(id: items.map(&:id))
|
||||
end
|
||||
# returns ActiveRecord.Relation
|
||||
items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
|
||||
Status.where(id: items.map(&:id))
|
||||
end
|
||||
|
||||
def favourites_map(status_ids, account_id)
|
||||
@@ -553,9 +548,9 @@ class Status < ApplicationRecord
|
||||
end
|
||||
|
||||
def set_locality
|
||||
if account.domain.nil? && !attribute_changed?(:local_only)
|
||||
self.local_only = marked_local_only?
|
||||
end
|
||||
return unless account.domain.nil? && !attribute_changed?(:local_only)
|
||||
|
||||
self.local_only = marked_local_only?
|
||||
end
|
||||
|
||||
def set_conversation
|
||||
|
||||
@@ -244,7 +244,6 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def functional?
|
||||
|
||||
functional_or_moved?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user