2.0.0-rc2: Achievements Refactored & Admin improved.

This commit is contained in:
2026-08-09 01:34:20 +08:00
parent 3874bf57a9
commit 63a0751aba
29 changed files with 2143 additions and 355 deletions
+51 -8
View File
@@ -48,19 +48,63 @@ class JobStore:
finally:
db.close()
def list_jobs(self, limit: int = 20) -> List[Dict[str, Any]]:
def list_jobs(
self,
limit: int = 20,
status: Optional[str] = None,
job_type: Optional[str] = None,
offset: int = 0,
) -> List[Dict[str, Any]]:
db = self._connect()
try:
where = []
args = []
if status:
where.append('status = ?')
args.append(status)
if job_type:
where.append('job_type = ?')
args.append(job_type)
where_sql = f"WHERE {' AND '.join(where)}" if where else ''
args.extend([
max(1, min(int(limit), 100)),
max(0, int(offset)),
])
rows = db.execute(
f"""
SELECT *
FROM etl_jobs
{where_sql}
ORDER BY created_at DESC, id DESC
LIMIT ? OFFSET ?
""",
args,
).fetchall()
return [dict(row) for row in rows]
finally:
db.close()
def get_summary(self) -> Dict[str, int]:
db = self._connect()
try:
rows = db.execute(
"""
SELECT *
SELECT status, COUNT(*) AS count
FROM etl_jobs
ORDER BY created_at DESC, id DESC
LIMIT ?
""",
[max(1, min(int(limit), 100))],
GROUP BY status
"""
).fetchall()
return [dict(row) for row in rows]
summary = {
'total': 0,
'queued': 0,
'running': 0,
'succeeded': 0,
'failed': 0,
}
for row in rows:
summary[row['status']] = int(row['count'])
summary['total'] += int(row['count'])
return summary
finally:
db.close()
@@ -195,4 +239,3 @@ class JobStore:
db.commit()
finally:
db.close()