diff options
author | ysksn <bluewhale1982@gmail.com> | 2020-01-11 19:55:33 +0900 |
---|---|---|
committer | Yamagishi Kazutoshi <ykzts@desire.sh> | 2020-01-11 19:55:33 +0900 |
commit | 6f8f018e3ed7811998bf2cc10d1b6f0dad54dcef (patch) | |
tree | 629b16c031d47edc15502735b1e00ab91fc5fe93 /app/models/concerns | |
parent | c10ff359a2c4e1a24e04c80b1b9d46541efc1705 (diff) |
Refactor StatusThreadingConcern (#9626)
* Remove #filter_from_context? * Create scope Status.with_accounts Retrieving AR objects should be their model's scope
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/status_threading_concern.rb | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/app/models/concerns/status_threading_concern.rb b/app/models/concerns/status_threading_concern.rb index 15eb695cd..a0ead1995 100644 --- a/app/models/concerns/status_threading_concern.rb +++ b/app/models/concerns/status_threading_concern.rb @@ -81,12 +81,12 @@ module StatusThreadingConcern end def find_statuses_from_tree_path(ids, account, promote: false) - statuses = statuses_with_accounts(ids).to_a + statuses = Status.with_accounts(ids).to_a account_ids = statuses.map(&:account_id).uniq domains = statuses.map(&:account_domain).compact.uniq relations = relations_map_for_account(account, account_ids, domains) - statuses.reject! { |status| filter_from_context?(status, account, relations) } + statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? } # Order ancestors/descendants by tree path statuses.sort_by! { |status| ids.index(status.id) } @@ -125,12 +125,4 @@ module StatusThreadingConcern domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id), } end - - def statuses_with_accounts(ids) - Status.where(id: ids).includes(:account) - end - - def filter_from_context?(status, account, relations) - StatusFilter.new(status, account, relations).filtered? - end end |