This commit is contained in:
Nikolaj
2026-03-26 13:29:43 +01:00
parent 3a634e84ee
commit 6e23e32bb0
4 changed files with 33 additions and 1 deletions

View File

@@ -243,6 +243,7 @@ WIKIDATA_INSTANCE_TYPE_MAP = {
"Q24034552": CardType.science_thing, # mathematical concept
"Q12089225": CardType.science_thing, # mineral species
"Q55640599": CardType.science_thing, # group of chemical entities
"Q17339814": CardType.science_thing, # group or class of chemical substances
"Q119459661": CardType.science_thing, # scientific activity
"Q113145171": CardType.science_thing, # type of chemical entity

View File

@@ -163,6 +163,14 @@ def get_cards(user: UserModel = Depends(get_current_user), db: Session = Depends
for card in cards
]
@app.get("/cards/in-decks")
def get_cards_in_decks(user: UserModel = Depends(get_current_user), db: Session = Depends(get_db)):
deck_ids = [d.id for d in db.query(DeckModel).filter(DeckModel.user_id == user.id, DeckModel.deleted == False).all()]
if not deck_ids:
return []
card_ids = db.query(DeckCardModel.card_id).filter(DeckCardModel.deck_id.in_(deck_ids)).distinct().all()
return [str(row.card_id) for row in card_ids]
@app.post("/open_pack")
@limiter.limit("10/minute")
async def open_pack(request: Request, user: UserModel = Depends(get_current_user), db: Session = Depends(get_db)):