refactor(proxy): drop leftover group_by=tag branch and the tag page SQL-text test
Some checks are pending
Cost map pins recheck / rerun-cost-map-guard (push) Waiting to run
LiteLLM Rust DB / db-queries (push) Waiting to run
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run

The aggregated team report no longer reads the tag table, so the extra table check and its
comment did nothing. The tag page SQL-text test is replaced by the integration tests that
read real rows for team filtering, User-Agent exclusion, ordering and paging
This commit is contained in:
Mrinal Chanshetty 2026-10-29 14:25:03 -07:00
parent 9bc5ab73ac
commit 0bc9e64274
2 changed files with 1 additions and 35 deletions

View file

@ -59,7 +59,6 @@ from litellm.types.proxy.management_endpoints.common_daily_activity import (
UserActivityRow,
)
from litellm.types.repositories.daily_activity import (
DailyActivityTable,
ExportRow,
ExportType,
KeyMetadataRow,
@ -289,8 +288,7 @@ def _register_aggregated_route(router: APIRouter, resolver: EntityScopeResolver,
include_guardrail_breakdown=resolver.include_guardrail_breakdown,
api_key_limit=api_key_limit,
)
# PTU hours are a whole-team figure, so a team's per-tag breakdown carries none.
if resolver.entity != "team" or resolved.scope.table is not DailyActivityTable.TEAM:
if resolver.entity != "team":
return activity
return with_ptu_consumption(activity, llm_router, single_team_id(resolved.scope.entity_ids))
except HTTPException:

View file

@ -141,38 +141,6 @@ def test_key_page_sql_rejects_invalid_page_bounds(offset: int, limit: int, error
build_key_page_sql(_scope(), offset=offset, limit=limit)
def test_tag_page_sql_scopes_to_team_excludes_user_agents_and_orders_tags() -> None:
query: Final = build_tag_page_sql(
_scope(table=DailyActivityTable.TEAM, entity_ids=("team-a",), api_keys=("key-1",), model="gpt-test"),
team_id="team-a",
offset=7,
limit=3,
)
assert query.params == (
"2026-01-01",
"2026-01-31",
"gpt-test",
["key-1"],
"team-a",
PTU_SENTINEL_API_KEY,
3,
7,
)
assert 'FROM "LiteLLM_DailyTagSpend"' in query.sql
assert "team_id = $5" in query.sql
assert "api_key = ANY($4::text[])" in query.sql
assert "tag IS NOT NULL" in query.sql
assert "api_key <> $6" in query.sql
assert "NOT (LOWER(BTRIM(tag)) LIKE 'user-agent:%' OR LOWER(BTRIM(tag)) LIKE 'user agent:%')" in query.sql
assert "GROUP BY tag" in query.sql
assert "SUM(spend::numeric) AS rank_spend" in query.sql
assert "ORDER BY rank_spend DESC, tag ASC" in query.sql
assert "(SELECT COUNT(*) FROM ranked)::bigint AS total_tags" in query.sql
assert "LIMIT $7 OFFSET $8" in query.sql
assert '"tag" = ANY' not in query.sql
@pytest.mark.parametrize(
("offset", "limit", "error"),
(