mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
use view for getting tag usage on ui
This commit is contained in:
parent
4626c5a365
commit
43acf6d08f
1 changed files with 17 additions and 28 deletions
|
@ -48,15 +48,12 @@ async def ui_get_spend_by_tags(
|
||||||
# Get spend for all tags
|
# Get spend for all tags
|
||||||
sql_query = """
|
sql_query = """
|
||||||
SELECT
|
SELECT
|
||||||
jsonb_array_elements_text(request_tags) AS individual_request_tag,
|
individual_request_tag,
|
||||||
DATE(s."startTime") AS spend_date,
|
spend_date,
|
||||||
COUNT(*) AS log_count,
|
log_count,
|
||||||
SUM(spend) AS total_spend
|
total_spend
|
||||||
FROM "LiteLLM_SpendLogs" s
|
FROM DailyTagSpend
|
||||||
WHERE
|
WHERE spend_date >= $1::date AND spend_date <= $2::date
|
||||||
DATE(s."startTime") >= $1::date
|
|
||||||
AND DATE(s."startTime") <= $2::date
|
|
||||||
GROUP BY individual_request_tag, spend_date
|
|
||||||
ORDER BY total_spend DESC;
|
ORDER BY total_spend DESC;
|
||||||
"""
|
"""
|
||||||
response = await prisma_client.db.query_raw(
|
response = await prisma_client.db.query_raw(
|
||||||
|
@ -69,19 +66,11 @@ async def ui_get_spend_by_tags(
|
||||||
sql_query = """
|
sql_query = """
|
||||||
SELECT
|
SELECT
|
||||||
individual_request_tag,
|
individual_request_tag,
|
||||||
COUNT(*) AS log_count,
|
SUM(log_count) AS log_count,
|
||||||
SUM(spend) AS total_spend
|
SUM(total_spend) AS total_spend
|
||||||
FROM (
|
FROM DailyTagSpend
|
||||||
SELECT
|
WHERE spend_date >= $1::date AND spend_date <= $2::date
|
||||||
jsonb_array_elements_text(request_tags) AS individual_request_tag,
|
AND individual_request_tag = ANY($3::text[])
|
||||||
DATE(s."startTime") AS spend_date,
|
|
||||||
spend
|
|
||||||
FROM "LiteLLM_SpendLogs" s
|
|
||||||
WHERE
|
|
||||||
DATE(s."startTime") >= $1::date
|
|
||||||
AND DATE(s."startTime") <= $2::date
|
|
||||||
) AS subquery
|
|
||||||
WHERE individual_request_tag = ANY($3::text[])
|
|
||||||
GROUP BY individual_request_tag
|
GROUP BY individual_request_tag
|
||||||
ORDER BY total_spend DESC;
|
ORDER BY total_spend DESC;
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue