strankovani u deploys a styly pro pocitadla
This commit is contained in:
+37
-5
@@ -81,14 +81,11 @@ def update_app_resources(app_id: str, memory: str, cpus: str):
|
||||
con.close()
|
||||
|
||||
|
||||
def get_deployments(
|
||||
limit: int = 100,
|
||||
def build_deployment_filters(
|
||||
status: str | None = None,
|
||||
app_id: str | None = None,
|
||||
source: str | None = None,
|
||||
):
|
||||
con = get_connection()
|
||||
|
||||
filters = []
|
||||
params = []
|
||||
|
||||
@@ -116,6 +113,19 @@ def get_deployments(
|
||||
params.append(source)
|
||||
|
||||
where = f"WHERE {' AND '.join(filters)}" if filters else ""
|
||||
return where, params
|
||||
|
||||
|
||||
def get_deployments(
|
||||
limit: int = 20,
|
||||
offset: int = 0,
|
||||
status: str | None = None,
|
||||
app_id: str | None = None,
|
||||
source: str | None = None,
|
||||
):
|
||||
con = get_connection()
|
||||
where, params = build_deployment_filters(status=status, app_id=app_id, source=source)
|
||||
|
||||
rows = con.execute(
|
||||
f"""
|
||||
SELECT
|
||||
@@ -138,14 +148,36 @@ def get_deployments(
|
||||
END,
|
||||
id DESC
|
||||
LIMIT ?
|
||||
OFFSET ?
|
||||
""",
|
||||
(*params, *RUNNING_STATUSES, limit),
|
||||
(*params, *RUNNING_STATUSES, limit, offset),
|
||||
).fetchall()
|
||||
|
||||
con.close()
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
|
||||
def count_deployments(
|
||||
status: str | None = None,
|
||||
app_id: str | None = None,
|
||||
source: str | None = None,
|
||||
):
|
||||
con = get_connection()
|
||||
where, params = build_deployment_filters(status=status, app_id=app_id, source=source)
|
||||
|
||||
row = con.execute(
|
||||
f"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM deployments
|
||||
{where}
|
||||
""",
|
||||
params,
|
||||
).fetchone()
|
||||
|
||||
con.close()
|
||||
return row["count"] if row else 0
|
||||
|
||||
|
||||
def get_deployment_filter_options():
|
||||
con = get_connection()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user