diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-30 04:47:04 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-30 04:47:04 +0200 |
commit | 35933167c0c84033d062a6cc73213fc4c222e4d3 (patch) | |
tree | 243a02cc98ceba378a8cdad0d32047d0d4c2cae7 /app/models/status.rb | |
parent | bb7006bda1fac9b261944a51e497569cfcf2d1be (diff) |
Add counter caches for a large performance increase on API requests
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index d5bbf70fb..81b26fd14 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -10,11 +10,11 @@ class Status < ApplicationRecord belongs_to :application, class_name: 'Doorkeeper::Application' - belongs_to :account, inverse_of: :statuses + belongs_to :account, inverse_of: :statuses, counter_cache: true belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account' belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies - belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs + belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, counter_cache: :reblogs_count has_many :favourites, inverse_of: :status, dependent: :destroy has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy |