From 7c9033377b98070dd2820a47686e461ede4946f9 Mon Sep 17 00:00:00 2001 From: Rob Cannon Date: Tue, 29 Oct 2024 10:07:26 +0700 Subject: [PATCH] fix: issue with cg api where cache was being corrupted with a specific query combo --- balanced_backend/api/v1/endpoints/coingecko.py | 4 +++- balanced_backend/cache/cmc.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/balanced_backend/api/v1/endpoints/coingecko.py b/balanced_backend/api/v1/endpoints/coingecko.py index d57645b..78d34f5 100644 --- a/balanced_backend/api/v1/endpoints/coingecko.py +++ b/balanced_backend/api/v1/endpoints/coingecko.py @@ -66,8 +66,10 @@ async def get_coingecko_trades( response.headers["x-total-count"] = str(len(cache.coingecko_historical)) output = cache.coingecko_historical if type: + type_output = {} for k, v in output.items(): - output[k] = output[k][type] + type_output[k] = output[k][type] + return type_output return output try: output = cache.coingecko_historical[ticker_id] diff --git a/balanced_backend/cache/cmc.py b/balanced_backend/cache/cmc.py index da15dff..ba08b93 100644 --- a/balanced_backend/cache/cmc.py +++ b/balanced_backend/cache/cmc.py @@ -12,6 +12,9 @@ if TYPE_CHECKING: from sqlalchemy.orm import Session +# Ideal Endpoint Documentation +# https://docs.google.com/document/d/1S4urpzUnO2t7DmS_1dc4EL4tgnnbTObPYXvDeBnukCg/edit + def update_cmc_summary(session: 'Session'): logger.info("Updating cmc summary cache...")