Skip to content

Commit

Permalink
Merge pull request #292 from dataforgoodfr/fix_segment_not_json_seria…
Browse files Browse the repository at this point in the history
…lizable

fix: TypeError: Object of type Segment is not JSON serializable
  • Loading branch information
rv2931 authored Nov 22, 2024
2 parents 0419557 + 61363c4 commit 5538255
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/bloom/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## https://jayhawk24.hashnode.dev/how-to-implement-pagination-in-fastapi-feat-sqlalchemy
X_API_KEY_HEADER=APIKeyHeader(name="x-key")

from fastapi.encoders import jsonable_encoder

## FastAPI endpoint decorator to manage Redis caching
# Needs to add request:Request and nocache:bool parameters to all endpoints
Expand Down Expand Up @@ -45,7 +46,7 @@ async def wrapper(*args, **kwargs):
payload=json.loads(incache)
else:
payload=await func(*args, **kwargs)
cache_service.set(cache_key, json.dumps(payload))
cache_service.set(cache_key, json.dumps(jsonable_encoder(payload)))
cache_service.expire(cache_key,settings.redis_cache_expiration)
logger.debug(f"{cache_key} elapsed Time: {time.time()-start}")
return payload
Expand Down

0 comments on commit 5538255

Please sign in to comment.