Improving feed queries, switching API to doorkeeper authentication
This commit is contained in:
@ -11,7 +11,7 @@ class Feed
|
||||
# If we're after most recent items and none are there, we need to precompute the feed
|
||||
return PrecomputeFeedService.new.(@type, @account).take(limit) if unhydrated.empty? && offset == 0
|
||||
|
||||
Status.where(id: unhydrated).each { |status| status_map[status.id.to_s] = status }
|
||||
Status.where(id: unhydrated).with_includes.with_counters.each { |status| status_map[status.id.to_s] = status }
|
||||
return unhydrated.map { |id| status_map[id] }
|
||||
end
|
||||
|
||||
|
@ -14,6 +14,9 @@ class Status < ActiveRecord::Base
|
||||
validates :account, presence: true
|
||||
validates :uri, uniqueness: true, unless: 'local?'
|
||||
|
||||
scope :with_counters, -> { select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count') }
|
||||
scope :with_includes, -> { includes(:account, reblog: :account, thread: :account) }
|
||||
|
||||
def local?
|
||||
self.uri.nil?
|
||||
end
|
||||
|
Reference in New Issue
Block a user