Fix color less than or equal to

This commit is contained in:
Correl Roush 2022-07-27 22:14:00 -04:00
parent 37f2d37213
commit 1e635a4e63

View file

@ -1,5 +1,6 @@
import datetime
import decimal
import itertools
import logging
import typing
import uuid
@ -123,7 +124,14 @@ async def advanced_search(
constraints.append(f"cards.color_identity ILIKE %({param})s")
params[param] = tutor.models.Color.to_string(criterion.colors)
if criterion.operator == tutor.search.Operator.lte:
colors = list({str(color) for color in criterion.colors} | {""})
colors = list(
{
tutor.models.Color.to_string(list(combo))
for n in range(len(criterion.colors))
for combo in itertools.combinations(criterion.colors, n + 1)
}
| {""}
)
constraints.append(
"({})".format(
" OR ".join(