Had them before, but were not used in frontend:
@router.get("/characters/", response_model=List[Character])
def get_characters(name: Optional[str] = None, origin: Optional[str] = None, db: Session = Depends(get_db)):
filters = {}
if name:
filters['name'] = name
if origin:
filters['origin'] = origin
characters = crud.get_characters(db, **filters)
if not characters:
raise HTTPException(status_code=404, detail="Characters not found")
return characters
@router.get("/monsters/", response_model=List[Monster])
def get_monsters(name: Optional[str] = None, game: Optional[str] = None, db: Session = Depends(get_db)):
filters = {}
if name:
filters['name'] = name
if game:
filters['game'] = game
monsters = crud.get_monsters(db, **filters)
if not monsters:
raise HTTPException(status_code=404, detail="Characters not found")
else:
# Sanitize response data
sanitized_monsters = []
for monster in monsters:
if monster.elementalAffinity is None:
monster.elementalAffinity = ""
sanitized_monsters.append(monster)
return sanitized_monsters
If using these (or similar), need to make sure used in client side.
But not necessarily so trivial to combine with the "dropdown" option that also works in tandem
with filtering by game/origin
Had them before, but were not used in frontend:
If using these (or similar), need to make sure used in client side.
But not necessarily so trivial to combine with the "dropdown" option that also works in tandem
with filtering by game/origin