Skip to content

Commit

Permalink
port tootsuite#11139 to monsterfork: Remove expensive counters from f…
Browse files Browse the repository at this point in the history
…ederation page in admin UI
  • Loading branch information
Gargron authored and multiple creatures committed Feb 21, 2020
1 parent b4d97bc commit 38c7f79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 2 additions & 6 deletions app/models/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ def initialize(resource)
@updated_at = resource.is_a?(DomainBlock) ? resource.updated_at : 0
end

def cached_sample_accounts
Rails.cache.fetch("#{cache_key}/sample_accounts", expires_in: 12.hours) { Account.where(domain: domain).searchable.joins(:account_stat).popular.limit(3) }
end

def cached_accounts_count
@accounts_count || Rails.cache.fetch("#{cache_key}/count", expires_in: 12.hours) { Account.where(domain: domain).count }
def countable?
@accounts_count.present?
end

def to_param
Expand Down
13 changes: 7 additions & 6 deletions app/views/admin/instances/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@
%h4
= instance.domain
%small
= t('admin.instances.known_accounts', count: instance.cached_accounts_count)

- if instance.domain_block
- first_item = true
- if !instance.domain_block.noop?
•
= t("admin.domain_blocks.severity.#{instance.domain_block.severity}")
- first_item = false
- if instance.domain_block.reject_media?
•
- unless first_item
•
= t('admin.domain_blocks.rejecting_media')
- first_item = false
- if instance.domain_block.reject_reports?
•
- unless first_item
•
= t('admin.domain_blocks.rejecting_reports')
- if instance.domain_block.reason
= simple_format(h("Policy reason: #{instance.domain_block.reason}"))
Expand All @@ -59,5 +61,4 @@
= t('admin.accounts.no_limits_imposed')
- if instance.countable?
.trends__item__current{ title: t('admin.instances.known_accounts', count: instance.accounts_count) }= number_to_human instance.accounts_count, strip_insignificant_zeros: true

= paginate paginated_instances

0 comments on commit 38c7f79

Please sign in to comment.