Skip to content

Commit

Permalink
Fix invisible results and single-card combo results in find my combos
Browse files Browse the repository at this point in the history
  • Loading branch information
ldeluigi committed Jan 7, 2025
1 parent 3bbd03f commit 966568d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions backend/spellbook/views/find_my_combos.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ def to_representation(self, data):
if variant_commanders.issubset(deck.commanders):
if variant_cards.issubset(cards):
included_variants.append(variant_data)
elif variant_cards.intersection(cards):
else:
if set(variant_identity).issubset(identity_set):
almost_included_variants.append(variant_data)
else:
almost_included_variants_by_adding_colors.append(variant_data)
elif variant_cards.issubset(cards):
included_variants_by_changing_commanders.append(variant_data)
elif variant_cards.intersection(cards):
else:
if set(variant_identity).issubset(identity_set):
almost_included_variants_by_changing_commanders.append(variant_data)
else:
Expand Down Expand Up @@ -169,8 +169,14 @@ def get(self, request: Request) -> Response:

variant_id_list = CardInVariant.objects \
.values('variant_id') \
.alias(missing_count=Sum(Greatest(F('quantity') - quantity_in_deck, Value(0)))) \
.filter(missing_count__lte=1)
.alias(
missing_count=Sum(Greatest(F('quantity') - quantity_in_deck, Value(0))),
total_count=Sum('quantity'),
) \
.filter(
missing_count__lte=1,
total_count__gte=2,
)

viewset = VariantViewSet()
viewset.setup(self.request)
Expand Down

0 comments on commit 966568d

Please sign in to comment.