about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/follow_request.rb2
-rw-r--r--app/models/instance.rb6
3 files changed, 7 insertions, 3 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 6b539f004..a82251d2e 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -98,7 +98,7 @@ class Account < ApplicationRecord
   scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
   scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
   scope :searchable, -> { without_suspended.where(moved_to_account_id: nil) }
-  scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)).by_recent_status }
+  scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)) }
   scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) }
   scope :by_recent_status, -> { order(Arel.sql('(case when account_stats.last_status_at is null then 1 else 0 end) asc, account_stats.last_status_at desc')) }
   scope :popular, -> { order('account_stats.followers_count desc') }
diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb
index c5451a050..96ac7eaa5 100644
--- a/app/models/follow_request.rb
+++ b/app/models/follow_request.rb
@@ -26,7 +26,7 @@ class FollowRequest < ApplicationRecord
 
   def authorize!
     account.follow!(target_account, reblogs: show_reblogs, uri: uri)
-    MergeWorker.perform_async(target_account.id, account.id)
+    MergeWorker.perform_async(target_account.id, account.id) if account.local?
     destroy!
   end
 
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