Skip to content

Commit 2a7b4de

Browse files
committed
[batch] add billing quotes API routes and openapi spec
1 parent 6ec7c53 commit 2a7b4de

4 files changed

Lines changed: 990 additions & 366 deletions

File tree

‎batch/batch/billing_reporting.py‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -116,51 +116,6 @@ async def query_billing_projects_with_cost(
116116
return billing_projects
117117

118118

119-
async def query_billing_projects_without_cost(
120-
db: Database, user: Optional[str] = None, billing_project: Optional[str] = None, status: Optional[str] = None
121-
) -> List[Dict[str, Any]]:
122-
where_conditions = ["billing_projects.`status` != 'deleted'"]
123-
args = []
124-
125-
if user:
126-
where_conditions.append("JSON_CONTAINS(users, JSON_QUOTE(%s))")
127-
args.append(user)
128-
129-
if billing_project:
130-
where_conditions.append('billing_projects.name_cs = %s')
131-
args.append(billing_project)
132-
133-
if status:
134-
where_conditions.append('billing_projects.`status` = %s')
135-
args.append(status)
136-
137-
if where_conditions:
138-
where_condition = f'WHERE {" AND ".join(where_conditions)}'
139-
else:
140-
where_condition = ''
141-
142-
sql = f"""
143-
SELECT billing_projects.name as billing_project,
144-
billing_projects.`status` as `status`,
145-
users, `limit`
146-
FROM billing_projects
147-
LEFT JOIN LATERAL (
148-
SELECT billing_project, JSON_ARRAYAGG(`user_cs`) as users
149-
FROM billing_project_users
150-
WHERE billing_project_users.billing_project = billing_projects.name
151-
GROUP BY billing_project_users.billing_project
152-
) AS t ON TRUE
153-
{where_condition};
154-
"""
155-
156-
billing_projects = []
157-
async for record in db.select_and_fetchall(sql, tuple(args)):
158-
record['users'] = json.loads(record['users']) if record['users'] is not None else []
159-
billing_projects.append(record)
160-
161-
return billing_projects
162-
163-
164119
async def query_billing_history(
165120
db: Database,
166121
start: datetime.datetime,

0 commit comments

Comments
 (0)