Skip to content

Commit b03be7c

Browse files
committed
Add exclude_card_id to decklist_resource
1 parent c600632 commit b03be7c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/resources/decklist_resource.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ class DecklistResource < ApplicationResource
3636
end
3737
end
3838

39+
# Will return decklists that do NOT contain any of the specified cards.
40+
filter :exclude_card_id, :string do
41+
eq do |scope, card_ids|
42+
scope.left_joins(:decklist_cards)
43+
.group('decklists.id')
44+
.having('COUNT(CASE WHEN decklists_cards.card_id IN (?) THEN 1 END) = 0', card_ids)
45+
end
46+
end
47+
3948
attribute :card_slots, :hash
4049
attribute :num_cards, :integer
4150
attribute :influence_spent, :integer

0 commit comments

Comments
 (0)