about summary refs log tree commit diff
path: root/app/models/instance.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-26 16:02:54 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-26 16:02:54 +0100
commitb9f314bba754074c7ac7dad37cdd35a0cbf1d1b5 (patch)
tree987f8ceff468686d7f4185cf2312e56aed45ecd1 /app/models/instance.rb
parent648cf8bfd51913929b7d0d3a637de496d6e40f89 (diff)
parent0c1a05b281c2665b52a644d51b9b06c2756479a7 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- config/locales/es.yml
- config/locales/pl.yml
- config/locales/pt-BR.yml
Diffstat (limited to 'app/models/instance.rb')
-rw-r--r--app/models/instance.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/instance.rb b/app/models/instance.rb
index 7448d465c..7bf000d40 100644
--- a/app/models/instance.rb
+++ b/app/models/instance.rb
@@ -7,7 +7,7 @@ class Instance
 
   def initialize(resource)
     @domain         = resource.domain
-    @accounts_count = resource.accounts_count
+    @accounts_count = resource.is_a?(DomainBlock) ? nil : resource.accounts_count
     @domain_block   = resource.is_a?(DomainBlock) ? resource : DomainBlock.find_by(domain: domain)
   end
 
@@ -15,6 +15,10 @@ class Instance
     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 }
+  end
+
   def to_param
     domain
   end