mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-02-07 15:32:13 -05:00
Fix rubocop error and cleanup Status.as_direct_timeline
a little
This commit is contained in:
parent
d3136e6d58
commit
edf6ca56e3
@ -344,23 +344,23 @@ class Status < ApplicationRecord
|
|||||||
|
|
||||||
# _from_me part does not require any timeline filters
|
# _from_me part does not require any timeline filters
|
||||||
query_from_me = where(account_id: account.id)
|
query_from_me = where(account_id: account.id)
|
||||||
.where(Status.arel_table[:visibility].eq(3))
|
.direct_visibility
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.order('statuses.id DESC')
|
.order(id: :desc)
|
||||||
|
|
||||||
# _to_me part requires mute and block filter.
|
# _to_me part requires mute and block filter.
|
||||||
# FIXME: may we check mutes.hide_notifications?
|
# FIXME: may we check mutes.hide_notifications?
|
||||||
query_to_me = Status
|
query_to_me = Status
|
||||||
|
.direct_visibility
|
||||||
.joins(:mentions)
|
.joins(:mentions)
|
||||||
.merge(Mention.where(account_id: account.id))
|
.where(mentions: { account_id: account.id })
|
||||||
.where(Status.arel_table[:visibility].eq(3))
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.order('mentions.status_id DESC')
|
.order('mentions.status_id DESC')
|
||||||
.not_excluded_by_account(account)
|
.not_excluded_by_account(account)
|
||||||
|
|
||||||
if max_id.present?
|
if max_id.present?
|
||||||
query_from_me = query_from_me.where('statuses.id < ?', max_id)
|
query_from_me = query_from_me.where(id: ...max_id)
|
||||||
query_to_me = query_to_me.where('mentions.status_id < ?', max_id)
|
query_to_me = query_to_me.where(mentions: { status_id: ...max_id })
|
||||||
end
|
end
|
||||||
|
|
||||||
if since_id.present?
|
if since_id.present?
|
||||||
@ -368,9 +368,9 @@ class Status < ApplicationRecord
|
|||||||
query_to_me = query_to_me.where('mentions.status_id > ?', since_id)
|
query_to_me = query_to_me.where('mentions.status_id > ?', since_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns ActiveRecord.Relation
|
# TODO: use a single query?
|
||||||
items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
|
ids = (query_from_me.pluck(:id) + query_to_me.pluck(:id)).sort.uniq.reverse.take(limit)
|
||||||
Status.where(id: items.map(&:id))
|
Status.where(id: ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def favourites_map(status_ids, account_id)
|
def favourites_map(status_ids, account_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user