Add counter caches for a large performance increase on API requests

This commit is contained in:
Eugen Rochko
2017-03-30 04:47:04 +02:00
parent bb7006bda1
commit 35933167c0
13 changed files with 41 additions and 22 deletions

View File

@@ -3,8 +3,8 @@
class Follow < ApplicationRecord
include Paginable
belongs_to :account
belongs_to :target_account, class_name: 'Account'
belongs_to :account, counter_cache: :following_count
belongs_to :target_account, class_name: 'Account', counter_cache: :followers_count
has_one :notification, as: :activity, dependent: :destroy