diff --git a/qiita_db/test/test_user.py b/qiita_db/test/test_user.py index 449f1535d..f15d70459 100644 --- a/qiita_db/test/test_user.py +++ b/qiita_db/test/test_user.py @@ -450,14 +450,26 @@ def test_user_artifacts(self): qdb.artifact.Artifact(7)]} self.assertEqual(obs, exp) - def test_jobs(self): + def test_jobs_all(self): PJ = qdb.processing_job.ProcessingJob + ignore_status = [] # generates expected jobs - jobs = qdb.user.User('shared@foo.bar').jobs() + jobs = qdb.user.User('shared@foo.bar').jobs(ignore_status) self.assertEqual(jobs, [ PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55'), PJ('b72369f9-a886-4193-8d3d-f7b504168e75')]) + # no jobs + self.assertEqual(qdb.user.User('admin@foo.bar').jobs( + ignore_status), []) + + def test_jobs_defaults(self): + PJ = qdb.processing_job.ProcessingJob + # generates expected jobs + jobs = qdb.user.User('shared@foo.bar').jobs() + self.assertEqual(jobs, [ + PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55')]) + # no jobs self.assertEqual(qdb.user.User('admin@foo.bar').jobs(), []) diff --git a/qiita_db/user.py b/qiita_db/user.py index 415cbaa63..bd6a648d0 100644 --- a/qiita_db/user.py +++ b/qiita_db/user.py @@ -661,11 +661,13 @@ def delete_messages(self, messages): qdb.sql_connection.TRN.add(sql) qdb.sql_connection.TRN.execute() - def jobs(self): + def jobs(self, ignore_status=['success']): """Return jobs created by the user Parameters ---------- + ignore_status, list of str + don't retieve jobs that have one of these status Returns ------- @@ -673,11 +675,29 @@ def jobs(self): """ with qdb.sql_connection.TRN: - sql_info = [self._id] sql = """SELECT processing_job_id FROM qiita.processing_job + LEFT JOIN qiita.processing_job_status + USING (processing_job_status_id) WHERE email = %s - ORDER BY heartbeat DESC""" + """ + + if ignore_status: + sql_info = [self._id, tuple(ignore_status)] + sql += " AND processing_job_status NOT IN %s" + else: + sql_info = [self._id] + + sql += """ + ORDER BY CASE processing_job_status + WHEN 'in_construction' THEN 1 + WHEN 'running' THEN 2 + WHEN 'queued' THEN 3 + WHEN 'waiting' THEN 4 + WHEN 'error' THEN 5 + WHEN 'success' THEN 6 + END, heartbeat DESC""" + qdb.sql_connection.TRN.add(sql, sql_info) return [qdb.processing_job.ProcessingJob(p[0]) for p in qdb.sql_connection.TRN.execute_fetchindex()] diff --git a/qiita_pet/handlers/api_proxy/tests/test_user.py b/qiita_pet/handlers/api_proxy/tests/test_user.py index ac5e55bfa..8823bcce7 100644 --- a/qiita_pet/handlers/api_proxy/tests/test_user.py +++ b/qiita_pet/handlers/api_proxy/tests/test_user.py @@ -46,24 +46,8 @@ def test_user_jobs_get_req(self): 'threads': 1, 'sortmerna_coverage': 0.97}, 'name': 'Pick closed-reference OTUs', - 'processing_job_workflow_id': ''}, - {'id': 'b72369f9-a886-4193-8d3d-f7b504168e75', - 'status': 'success', - 'heartbeat': '2015-11-22 21:15:00', - 'params': { - 'max_barcode_errors': 1.5, - 'sequence_max_n': 0, - 'max_bad_run_length': 3, - 'phred_offset': u'auto', - 'rev_comp': False, - 'phred_quality_threshold': 3, - 'input_data': 1, - 'rev_comp_barcode': False, - 'rev_comp_mapping_barcodes': True, - 'min_per_read_length_fraction': 0.75, - 'barcode_type': u'golay_12'}, - 'name': 'Split libraries FASTQ', - 'processing_job_workflow_id': 1}]} + 'step': 'generating demux file', + 'processing_job_workflow_id': ''}]} self.assertEqual(obs, exp) diff --git a/qiita_pet/handlers/api_proxy/user.py b/qiita_pet/handlers/api_proxy/user.py index d5edd2ceb..ab5a1fd80 100644 --- a/qiita_pet/handlers/api_proxy/user.py +++ b/qiita_pet/handlers/api_proxy/user.py @@ -11,26 +11,26 @@ @execute_as_transaction -def user_jobs_get_req(user): +def user_jobs_get_req(user, limit=30): """Gets the json of jobs Parameters ---------- - prep_id : int - PrepTemplate id to get info for - user_id : str - User requesting the sample template info + user : User + The user from which you want to return all jobs + limit : int, optional + Maximum jobs to send, negative values will return all Returns ------- dict of objects {'status': status, 'message': message, - 'template': {sample: {column: value, ...}, ...} + 'template': {{column: value, ...}, ...} """ response = [] - for j in user.jobs(): + for i, j in enumerate(user.jobs()): name = j.command.name hb = j.heartbeat hb = "" if hb is None else hb.strftime("%Y-%m-%d %H:%M:%S") @@ -42,6 +42,7 @@ def user_jobs_get_req(user): 'params': j.parameters.values, 'status': j.status, 'heartbeat': hb, + 'step': j.step, 'processing_job_workflow_id': wid}) return {'status': 'success', diff --git a/qiita_pet/static/css/style.css b/qiita_pet/static/css/style.css index dcb209a1a..811280431 100644 --- a/qiita_pet/static/css/style.css +++ b/qiita_pet/static/css/style.css @@ -1,9 +1,29 @@ +#qiita-main { + position: relative; + height: 100%; + width: 100%; +} +#qiita-processing { + position: absolute; + height: 100%; + width: 0%; + right: 0; + top: 0; +} #template-content{ padding: 10px; height: 100%; width: 100%; } +td.more-info-processing-jobs{ + cursor: pointer; + background: url('../img//details_open.png') no-repeat center center; +} +tr.shown td.more-info-processing-jobs { + background: url('../img//details_close.png') no-repeat center center; +} + /* table in the study description that holds the investigation type elements */ .investigation-type-table td { padding-top: 6px; diff --git a/qiita_pet/static/img/details_close.png b/qiita_pet/static/img/details_close.png new file mode 100644 index 000000000..fcc23c63e Binary files /dev/null and b/qiita_pet/static/img/details_close.png differ diff --git a/qiita_pet/static/img/details_open.png b/qiita_pet/static/img/details_open.png new file mode 100644 index 000000000..6f034d0f2 Binary files /dev/null and b/qiita_pet/static/img/details_open.png differ diff --git a/qiita_pet/static/js/qiita.js b/qiita_pet/static/js/qiita.js index 414c790ed..f9d555fc2 100644 --- a/qiita_pet/static/js/qiita.js +++ b/qiita_pet/static/js/qiita.js @@ -29,18 +29,50 @@ function bootstrapAlert(message, severity, timeout){ alertDiv.append('
Need help? Send us an email.
'); } - $('body').prepend(alertDiv); + $('#qiita-main').prepend(alertDiv); if(timeout > 0) { window.setTimeout(function() { $('#alert-message').alert('close'); }, timeout); } } +function format_extra_info_processing_jobs ( data ) { + // `data` is the original data object for the row + // 0: blank +/- button + // 1: heartbeat + // 2: name + // 3: status + // 4: step + // 5: id + // 6: params + // 7: processing_job_workflow_id + + let row = 'ID: | '+ + ''+ data[5] +' | '+ + '
Parameters:'+ data[6] +' | '+
+ '|
'+ + ''+ + ' | ' + '