Commiting
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountRelationshipsPresenter
|
||||
attr_reader :following, :followed_by, :blocking, :blocked_by,
|
||||
:muting, :requested, :domain_blocking,
|
||||
:endorsed
|
||||
attr_reader :following, :followed_by, :blocking,
|
||||
:blocked_by, :muting, :requested
|
||||
|
||||
def initialize(account_ids, current_account_id, **options)
|
||||
@account_ids = account_ids.map { |a| a.is_a?(Account) ? a.id : a }
|
||||
@@ -15,8 +14,6 @@ class AccountRelationshipsPresenter
|
||||
@blocked_by = cached[:blocked_by].merge(Account.blocked_by_map(@uncached_account_ids, @current_account_id))
|
||||
@muting = cached[:muting].merge(Account.muting_map(@uncached_account_ids, @current_account_id))
|
||||
@requested = cached[:requested].merge(Account.requested_map(@uncached_account_ids, @current_account_id))
|
||||
@domain_blocking = cached[:domain_blocking].merge(Account.domain_blocking_map(@uncached_account_ids, @current_account_id))
|
||||
@endorsed = cached[:endorsed].merge(Account.endorsed_map(@uncached_account_ids, @current_account_id))
|
||||
|
||||
cache_uncached!
|
||||
|
||||
@@ -26,8 +23,6 @@ class AccountRelationshipsPresenter
|
||||
@blocked_by.merge!(options[:blocked_by_map] || {})
|
||||
@muting.merge!(options[:muting_map] || {})
|
||||
@requested.merge!(options[:requested_map] || {})
|
||||
@domain_blocking.merge!(options[:domain_blocking_map] || {})
|
||||
@endorsed.merge!(options[:endorsed_map] || {})
|
||||
end
|
||||
|
||||
private
|
||||
@@ -42,8 +37,6 @@ class AccountRelationshipsPresenter
|
||||
blocked_by: {},
|
||||
muting: {},
|
||||
requested: {},
|
||||
domain_blocking: {},
|
||||
endorsed: {},
|
||||
}
|
||||
|
||||
@uncached_account_ids = []
|
||||
@@ -70,8 +63,6 @@ class AccountRelationshipsPresenter
|
||||
blocked_by: { account_id => blocked_by[account_id] },
|
||||
muting: { account_id => muting[account_id] },
|
||||
requested: { account_id => requested[account_id] },
|
||||
domain_blocking: { account_id => domain_blocking[account_id] },
|
||||
endorsed: { account_id => endorsed[account_id] },
|
||||
}
|
||||
|
||||
Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day)
|
||||
|
||||
@@ -6,9 +6,6 @@ class InstancePresenter
|
||||
:site_title,
|
||||
:site_short_description,
|
||||
:site_description,
|
||||
:site_extended_description,
|
||||
:site_terms,
|
||||
:closed_registrations_message,
|
||||
to: Setting
|
||||
)
|
||||
|
||||
@@ -25,6 +22,7 @@ class InstancePresenter
|
||||
end
|
||||
|
||||
def status_count
|
||||
puts "tilly-hello-1"
|
||||
Rails.cache.fetch('local_status_count') { Account.local.joins(:account_stat).sum('account_stats.statuses_count') }.to_i
|
||||
end
|
||||
|
||||
@@ -47,9 +45,5 @@ class InstancePresenter
|
||||
def thumbnail
|
||||
@thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
|
||||
end
|
||||
|
||||
def hero
|
||||
@hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,32 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StatusRelationshipsPresenter
|
||||
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map, :group_pins_map, :bookmarks_map
|
||||
attr_reader :reblogs_map, :favourites_map, :group_pins_map
|
||||
|
||||
def initialize(statuses, current_account_id = nil, **options)
|
||||
if current_account_id.nil?
|
||||
@reblogs_map = {}
|
||||
@reblogs_map = {}
|
||||
@favourites_map = {}
|
||||
@mutes_map = {}
|
||||
@bookmarks_map = {}
|
||||
@pins_map = {}
|
||||
@group_pins_map = {}
|
||||
else
|
||||
statuses = statuses.compact
|
||||
status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id, s.quote_of_id] }.uniq.compact
|
||||
conversation_ids = statuses.map(&:conversation_id).compact.uniq
|
||||
pinnable_status_ids = statuses.map(&:proper).select { |s| s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) }.map(&:id)
|
||||
statuses = statuses.compact
|
||||
status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id, s.quote_of_id] }.uniq.compact
|
||||
|
||||
@reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {})
|
||||
@reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {})
|
||||
@favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {})
|
||||
@mutes_map = Status.mutes_map(conversation_ids, current_account_id).merge(options[:mutes_map] || {})
|
||||
@bookmarks_map = Status.bookmarks_map(status_ids, current_account_id).merge(options[:bookmarks_map] || {})
|
||||
@pins_map = Status.pins_map(pinnable_status_ids, current_account_id).merge(options[:pins_map] || {})
|
||||
if options[:group_id]
|
||||
@group_pins_map = Status.group_pins_map(status_ids, options[:group_id]).merge(options[:group_pins_map] || {})
|
||||
else
|
||||
@group_pins_map = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user