Skip to content

Commit

Permalink
fix float conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nulinspiratie committed Jul 11, 2024
1 parent 34a4cf4 commit a63c31b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/qualibrate_app/api/routes/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
snapshot_router = APIRouter(prefix="/snapshot/{id}", tags=["snapshot"])


def is_float(string):
try:
float(string)
return True
except ValueError:
return False


def _get_snapshot_instance(
id: Annotated[IdType, Path()],
settings: Annotated[QualibrateSettings, Depends(get_settings)],
Expand Down Expand Up @@ -100,7 +108,7 @@ def update_entity(
value = int(value)
elif value.lower() in ["true", "false"]:
value = value.lower() == "true"
elif value.isnumeric():
elif is_float(value):
value = float(value)
updated = snapshot.update_entry({data_path: value})
if updated:
Expand Down

0 comments on commit a63c31b

Please sign in to comment.