mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix use view for getting tag usage
This commit is contained in:
parent
43acf6d08f
commit
67751d0ecc
1 changed files with 19 additions and 1 deletions
|
@ -974,7 +974,7 @@ class PrismaClient:
|
|||
)
|
||||
"""
|
||||
)
|
||||
if ret[0]["sum"] == 7:
|
||||
if ret[0]["sum"] == 8:
|
||||
print("All necessary views exist!") # noqa
|
||||
return
|
||||
except Exception:
|
||||
|
@ -1124,6 +1124,24 @@ class PrismaClient:
|
|||
|
||||
print("MonthlyGlobalSpendPerUserPerKey Created!") # noqa
|
||||
|
||||
try:
|
||||
await self.db.query_raw("""SELECT 1 FROM "DailyTagSpend" LIMIT 1""")
|
||||
print("DailyTagSpend Exists!") # noqa
|
||||
except Exception as e:
|
||||
sql_query = """
|
||||
CREATE OR REPLACE VIEW DailyTagSpend AS
|
||||
SELECT
|
||||
jsonb_array_elements_text(request_tags) AS individual_request_tag,
|
||||
DATE(s."startTime") AS spend_date,
|
||||
COUNT(*) AS log_count,
|
||||
SUM(spend) AS total_spend
|
||||
FROM "LiteLLM_SpendLogs" s
|
||||
GROUP BY individual_request_tag, DATE(s."startTime");
|
||||
"""
|
||||
await self.db.execute_raw(query=sql_query)
|
||||
|
||||
print("DailyTagSpend Created!") # noqa
|
||||
|
||||
try:
|
||||
await self.db.query_raw(
|
||||
"""SELECT 1 FROM "Last30dTopEndUsersSpend" LIMIT 1"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue