Implement dupes flag in GET /cards
This commit is contained in:
parent
5f150ebe5a
commit
a7bfcaaff1
13
main.py
13
main.py
@ -2221,6 +2221,19 @@ async def v1_cards_get(
|
|||||||
all_cards = all_cards.order_by(-Card.id)
|
all_cards = all_cards.order_by(-Card.id)
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
all_cards = all_cards.limit(limit)
|
all_cards = all_cards.limit(limit)
|
||||||
|
if dupes:
|
||||||
|
if team_id is None:
|
||||||
|
raise HTTPException(status_code=400, detail='Dupe checking must include a team_id')
|
||||||
|
logging.info(f'dupe check')
|
||||||
|
p_query = Card.select(Card.player).where(Card.team_id == team_id)
|
||||||
|
seen = set()
|
||||||
|
dupes = []
|
||||||
|
for x in p_query:
|
||||||
|
if x.player.player_id in seen:
|
||||||
|
dupes.append(x.player_id)
|
||||||
|
else:
|
||||||
|
seen.add(x.player_id)
|
||||||
|
all_cards = all_cards.where(Card.player_id << dupes)
|
||||||
|
|
||||||
# if all_cards.count() == 0:
|
# if all_cards.count() == 0:
|
||||||
# db.close()
|
# db.close()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user