about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-01-23 18:13:55 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-01-23 18:24:01 +0100
commit61ef81c548a0140a80281d4004ac55873d8f74d6 (patch)
tree770c251059d139243b9cb557c762648e0af55037 /app/models/status.rb
parent4d0383d75ac606f8c9c2b8ecb0ea2dddf28213cb (diff)
parent0a120d86d28e3f2e20455f56c1656f5d5f2f4af6 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `spec/models/status_spec.rb`:
  Upstream added tests too close to glitch-soc-specific tests.
  Kept both tests.
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index d57026354..9bb2b3746 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -103,15 +103,12 @@ class Status < ApplicationRecord
   scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }
   scope :not_domain_blocked_by_account, ->(account) { account.excluded_from_timeline_domains.blank? ? left_outer_joins(:account) : left_outer_joins(:account).where('accounts.domain IS NULL OR accounts.domain NOT IN (?)', account.excluded_from_timeline_domains) }
   scope :tagged_with_all, ->(tag_ids) {
-    Array(tag_ids).reduce(self) do |result, id|
+    Array(tag_ids).map(&:to_i).reduce(self) do |result, id|
       result.joins("INNER JOIN statuses_tags t#{id} ON t#{id}.status_id = statuses.id AND t#{id}.tag_id = #{id}")
     end
   }
   scope :tagged_with_none, ->(tag_ids) {
-    Array(tag_ids).reduce(self) do |result, id|
-      result.joins("LEFT OUTER JOIN statuses_tags t#{id} ON t#{id}.status_id = statuses.id AND t#{id}.tag_id = #{id}")
-            .where("t#{id}.tag_id IS NULL")
-    end
+    where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids)
   }
 
   scope :not_local_only, -> { where(local_only: [false, nil]) }