Skip to content

Commit 9237263

Browse files
committed
jobs list
1 parent 62a29de commit 9237263

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

app.py

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,7 +2959,7 @@ class JobsList(Resource):
29592959
@require_auth(keycloak_auth)
29602960
@require_permission('system_admin_access')
29612961
def get(self):
2962-
"""List all jobs from the jobs table"""
2962+
"""List all jobs from the jobs table with summary view"""
29632963

29642964
try:
29652965
with get_db_cursor() as cursor:
@@ -2970,16 +2970,70 @@ def get(self):
29702970

29712971
jobs = cursor.fetchall()
29722972

2973+
# Create summary view
2974+
jobs_summary = []
2975+
for job in jobs:
2976+
summary = {
2977+
'id': job['id'],
2978+
'status': job['status'],
2979+
'retry_count': job['retry_count'],
2980+
'created_at': job['created_at'],
2981+
'updated_at': job['updated_at']
2982+
}
2983+
2984+
# Extract useful info from payload if available
2985+
payload = job.get('payload', {})
2986+
if payload:
2987+
data = payload.get('data', {})
2988+
if 'submission_id' in data:
2989+
summary['submission_id'] = data['submission_id']
2990+
if 'split_on_fasta_headers' in data:
2991+
summary['split_on_fasta_headers'] = data['split_on_fasta_headers']
2992+
if 'job_type' in payload:
2993+
summary['job_type'] = payload['job_type']
2994+
2995+
jobs_summary.append(summary)
2996+
29732997
return {
2974-
'jobs': jobs,
2975-
'total': len(jobs)
2998+
'jobs': jobs_summary,
2999+
'total': len(jobs_summary)
29763000
}
29773001

29783002
except Exception as e:
29793003
logger.exception(f"Error retrieving jobs: {str(e)}")
29803004
return {'error': f'Database error: {str(e)}'}, 500
29813005

29823006

3007+
@admin_ns.route('/jobs/<string:job_id>')
3008+
class JobDetail(Resource):
3009+
3010+
### GET /jobs/<job_id> ###
3011+
3012+
@admin_ns.doc('get_job')
3013+
@require_auth(keycloak_auth)
3014+
@require_permission('system_admin_access')
3015+
def get(self, job_id):
3016+
"""Get full details of a specific job"""
3017+
3018+
try:
3019+
with get_db_cursor() as cursor:
3020+
cursor.execute("""
3021+
SELECT * FROM jobs
3022+
WHERE id = %s
3023+
""", (job_id,))
3024+
3025+
job = cursor.fetchone()
3026+
3027+
if not job:
3028+
return {'error': f'Job with id {job_id} not found'}, 404
3029+
3030+
return job
3031+
3032+
except Exception as e:
3033+
logger.exception(f"Error retrieving job {job_id}: {str(e)}")
3034+
return {'error': f'Database error: {str(e)}'}, 500
3035+
3036+
29833037

29843038
##########################
29853039
### DOWNLOAD

0 commit comments

Comments
 (0)