diff --git a/enterprise/utils.py b/enterprise/utils.py index 048c6e54f..f4916b689 100644 --- a/enterprise/utils.py +++ b/enterprise/utils.py @@ -95,5 +95,18 @@ async def view_spend_logs_from_clickhouse( 10 """ ) + + # get size of spend logs + num_rows = client.query("SELECT count(*) FROM default.spend_logs") + num_rows = num_rows.result_rows[0][0] + + # safely access num_rows.result_rows[0][0] + if num_rows is None: + num_rows = 0 + raw_rows = list(response.result_rows) - return raw_rows + response_data = { + "logs": raw_rows, + "log_count": num_rows, + } + return response_data diff --git a/litellm/integrations/clickhouse.py b/litellm/integrations/clickhouse.py index bf5223056..eb3947405 100644 --- a/litellm/integrations/clickhouse.py +++ b/litellm/integrations/clickhouse.py @@ -85,12 +85,6 @@ def _start_clickhouse(): # check if spend logs exist, if it does then return the schema response = client.query("DESCRIBE default.spend_logs") verbose_logger.debug(f"spend logs schema ={response.result_rows}") - # get all logs from spend logs - response = client.query("SELECT * FROM default.spend_logs") - verbose_logger.debug(f"spend logs ={response.result_rows}") - # get size of spend logs - response = client.query("SELECT count(*) FROM default.spend_logs") - verbose_logger.debug(f"spend logs count ={response.result_rows}") class ClickhouseLogger: diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index cdf57fe13..1b1ffa002 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6016,7 +6016,6 @@ async def health_readiness(): except Exception as e: index_info = "index does not exist - error: " + str(e) cache_type = {"type": cache_type, "index_info": index_info} - if prisma_client is not None: # if db passed in, check if it's connected await prisma_client.health_check() # test the db connection response_object = {"db": "connected"}