Skip to content

Commit

Permalink
fix: update state filtering logic to allow 'All' as a valid state (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli authored Nov 6, 2024
1 parent 3ad6cae commit 4430d2d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/routers/secure/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ async def get_items(
if Levenshtein.ratio(filter_lower, state_enum.name.lower()) >= 0.82:
filter_states.append(state_enum)
break
if len(filter_states) == len(states):
query = query.where(MediaItem.last_state.in_(filter_states))
else:
valid_states = [state_enum.name for state_enum in States]
raise HTTPException(
status_code=400,
detail=f"Invalid filter states: {states}. Valid states are: {valid_states}",
)
if 'All' not in states:
if len(filter_states) == len(states):
query = query.where(MediaItem.last_state.in_(filter_states))
else:
valid_states = [state_enum.name for state_enum in States]
raise HTTPException(
status_code=400,
detail=f"Invalid filter states: {states}. Valid states are: {valid_states}",
)

if type:
if "," in type:
Expand Down

0 comments on commit 4430d2d

Please sign in to comment.