Skip to content

Commit e64a22a

Browse files
authored
Merge pull request #2036 from antgonza/fix-1505
Fix 1505
2 parents 80c5fea + 2ead7a6 commit e64a22a

File tree

16 files changed

+561
-307
lines changed

16 files changed

+561
-307
lines changed

qiita_db/test/test_user.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,26 @@ def test_user_artifacts(self):
450450
qdb.artifact.Artifact(7)]}
451451
self.assertEqual(obs, exp)
452452

453-
def test_jobs(self):
453+
def test_jobs_all(self):
454454
PJ = qdb.processing_job.ProcessingJob
455+
ignore_status = []
455456
# generates expected jobs
456-
jobs = qdb.user.User('shared@foo.bar').jobs()
457+
jobs = qdb.user.User('shared@foo.bar').jobs(ignore_status)
457458
self.assertEqual(jobs, [
458459
PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55'),
459460
PJ('b72369f9-a886-4193-8d3d-f7b504168e75')])
460461

462+
# no jobs
463+
self.assertEqual(qdb.user.User('admin@foo.bar').jobs(
464+
ignore_status), [])
465+
466+
def test_jobs_defaults(self):
467+
PJ = qdb.processing_job.ProcessingJob
468+
# generates expected jobs
469+
jobs = qdb.user.User('shared@foo.bar').jobs()
470+
self.assertEqual(jobs, [
471+
PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55')])
472+
461473
# no jobs
462474
self.assertEqual(qdb.user.User('admin@foo.bar').jobs(), [])
463475

qiita_db/user.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,43 @@ def delete_messages(self, messages):
661661
qdb.sql_connection.TRN.add(sql)
662662
qdb.sql_connection.TRN.execute()
663663

664-
def jobs(self):
664+
def jobs(self, ignore_status=['success']):
665665
"""Return jobs created by the user
666666
667667
Parameters
668668
----------
669+
ignore_status, list of str
670+
don't retieve jobs that have one of these status
669671
670672
Returns
671673
-------
672674
list of ProcessingJob
673675
674676
"""
675677
with qdb.sql_connection.TRN:
676-
sql_info = [self._id]
677678
sql = """SELECT processing_job_id
678679
FROM qiita.processing_job
680+
LEFT JOIN qiita.processing_job_status
681+
USING (processing_job_status_id)
679682
WHERE email = %s
680-
ORDER BY heartbeat DESC"""
683+
"""
684+
685+
if ignore_status:
686+
sql_info = [self._id, tuple(ignore_status)]
687+
sql += " AND processing_job_status NOT IN %s"
688+
else:
689+
sql_info = [self._id]
690+
691+
sql += """
692+
ORDER BY CASE processing_job_status
693+
WHEN 'in_construction' THEN 1
694+
WHEN 'running' THEN 2
695+
WHEN 'queued' THEN 3
696+
WHEN 'waiting' THEN 4
697+
WHEN 'error' THEN 5
698+
WHEN 'success' THEN 6
699+
END, heartbeat DESC"""
700+
681701
qdb.sql_connection.TRN.add(sql, sql_info)
682702
return [qdb.processing_job.ProcessingJob(p[0])
683703
for p in qdb.sql_connection.TRN.execute_fetchindex()]

qiita_pet/handlers/api_proxy/tests/test_user.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,8 @@ def test_user_jobs_get_req(self):
4646
'threads': 1,
4747
'sortmerna_coverage': 0.97},
4848
'name': 'Pick closed-reference OTUs',
49-
'processing_job_workflow_id': ''},
50-
{'id': 'b72369f9-a886-4193-8d3d-f7b504168e75',
51-
'status': 'success',
52-
'heartbeat': '2015-11-22 21:15:00',
53-
'params': {
54-
'max_barcode_errors': 1.5,
55-
'sequence_max_n': 0,
56-
'max_bad_run_length': 3,
57-
'phred_offset': u'auto',
58-
'rev_comp': False,
59-
'phred_quality_threshold': 3,
60-
'input_data': 1,
61-
'rev_comp_barcode': False,
62-
'rev_comp_mapping_barcodes': True,
63-
'min_per_read_length_fraction': 0.75,
64-
'barcode_type': u'golay_12'},
65-
'name': 'Split libraries FASTQ',
66-
'processing_job_workflow_id': 1}]}
49+
'step': 'generating demux file',
50+
'processing_job_workflow_id': ''}]}
6751
self.assertEqual(obs, exp)
6852

6953

qiita_pet/handlers/api_proxy/user.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111

1212

1313
@execute_as_transaction
14-
def user_jobs_get_req(user):
14+
def user_jobs_get_req(user, limit=30):
1515
"""Gets the json of jobs
1616
1717
Parameters
1818
----------
19-
prep_id : int
20-
PrepTemplate id to get info for
21-
user_id : str
22-
User requesting the sample template info
19+
user : User
20+
The user from which you want to return all jobs
21+
limit : int, optional
22+
Maximum jobs to send, negative values will return all
2323
2424
Returns
2525
-------
2626
dict of objects
2727
{'status': status,
2828
'message': message,
29-
'template': {sample: {column: value, ...}, ...}
29+
'template': {{column: value, ...}, ...}
3030
"""
3131

3232
response = []
33-
for j in user.jobs():
33+
for i, j in enumerate(user.jobs()):
3434
name = j.command.name
3535
hb = j.heartbeat
3636
hb = "" if hb is None else hb.strftime("%Y-%m-%d %H:%M:%S")
@@ -42,6 +42,7 @@ def user_jobs_get_req(user):
4242
'params': j.parameters.values,
4343
'status': j.status,
4444
'heartbeat': hb,
45+
'step': j.step,
4546
'processing_job_workflow_id': wid})
4647

4748
return {'status': 'success',

qiita_pet/static/css/style.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
#qiita-main {
2+
position: relative;
3+
height: 100%;
4+
width: 100%;
5+
}
6+
#qiita-processing {
7+
position: absolute;
8+
height: 100%;
9+
width: 0%;
10+
right: 0;
11+
top: 0;
12+
}
113
#template-content{
214
padding: 10px;
315
height: 100%;
416
width: 100%;
517
}
618

19+
td.more-info-processing-jobs{
20+
cursor: pointer;
21+
background: url('../img//details_open.png') no-repeat center center;
22+
}
23+
tr.shown td.more-info-processing-jobs {
24+
background: url('../img//details_close.png') no-repeat center center;
25+
}
26+
727
/* table in the study description that holds the investigation type elements */
828
.investigation-type-table td {
929
padding-top: 6px;
841 Bytes
Loading

qiita_pet/static/img/details_open.png

881 Bytes
Loading

qiita_pet/static/js/qiita.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,50 @@ function bootstrapAlert(message, severity, timeout){
2929
alertDiv.append('<p style="text-align:center">Need help? Send us an <a href="mailto:qiita.help@gmail.com">email</a>.</p>');
3030
}
3131

32-
$('body').prepend(alertDiv);
32+
$('#qiita-main').prepend(alertDiv);
3333

3434
if(timeout > 0) {
3535
window.setTimeout(function() { $('#alert-message').alert('close'); }, timeout);
3636
}
3737
}
3838

39+
function format_extra_info_processing_jobs ( data ) {
40+
// `data` is the original data object for the row
41+
// 0: blank +/- button
42+
// 1: heartbeat
43+
// 2: name
44+
// 3: status
45+
// 4: step
46+
// 5: id
47+
// 6: params
48+
// 7: processing_job_workflow_id
49+
50+
let row = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
51+
'<tr>'+
52+
'<td><b>ID:</b></td>'+
53+
'<td>'+ data[5] +'</td>'+
54+
'</tr>'+
55+
'<tr>'+
56+
'<td colspan="2"><h5>Parameters:</h5>'+ data[6] +'</td>'+
57+
'</tr>';
58+
if (data[7] !== '' && data[3] === 'in_construction') {
59+
row += '<tr>'+
60+
'<td colspan="2">'+
61+
'<button class="btn btn-danger btn-sm" onclick="remove_job(\''+ data[5] + "', '" + data[7] +'\');">'+
62+
'<span class="glyphicon glyphicon-trash"></span></button>'+
63+
'</td>'
64+
'</tr>';
65+
}
66+
row += '</table>';
67+
68+
return row
69+
}
70+
71+
3972
function show_hide(div) {
4073
$('#' + div).toggle();
4174
}
4275

43-
4476
function delete_analysis(aname, analysis_id) {
4577
if (confirm('Are you sure you want to delete analysis: ' + aname + '?')) {
4678
var form = $("<form>")
@@ -58,3 +90,21 @@ function delete_analysis(aname, analysis_id) {
5890
form.submit();
5991
}
6092
}
93+
94+
function show_hide_process_list() {
95+
if ($("#qiita-main").width() == $("#qiita-main").parent().width()) {
96+
// let's update the job list
97+
processing_jobs_vue.update_processing_job_data();
98+
$("#qiita-main").width("76%");
99+
$("#user-studies-table").width("76%");
100+
$("#studies-table").width("76%");
101+
$("#qiita-processing").width("24%");
102+
$("#qiita-processing").show();
103+
} else {
104+
$("#qiita-main").width("100%");
105+
$("#user-studies-table").width("100%");
106+
$("#studies-table").width("100%");
107+
$("#qiita-processing").width("0%");
108+
$("#qiita-processing").hide();
109+
}
110+
}

qiita_pet/static/vendor/js/vue.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qiita_pet/templates/admin_approval.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{% extends sitebase.html %}
22
{% block head %}
3-
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">
4-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js" type="text/javascript"></script>
53

64
<script type="text/javascript">
75
$(document).ready(function() {

qiita_pet/templates/error_log.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
{% from future.utils import viewitems %}
44
{% from qiita_core.qiita_settings import qiita_config %}
55

6-
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">
7-
8-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>
9-
106
<script type="text/javascript">
117
$(document).ready(function() {
128
$('#error-table').dataTable({"order": [[1, "asc"]]});

qiita_pet/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% end %}
44

55
{%block content %}
6-
<div id="jumbotron" class="jumbotron">
6+
<div id="jumbotron" class="jumbotron" style="border-radius: 10px; padding: 30px">
77
<h1>{% raw portal_styling.index_header%}</h1>
88
{% raw portal_styling.index_text%}
99
</div>

qiita_pet/templates/list_studies.html

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@
55
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/select2.min.css" type="text/css">
66

77
<style>
8-
#alert-message {
9-
position: fixed;
10-
top: 50px;
11-
left: 40px;
12-
z-index:100;
13-
}
148
td.details-control {
159
cursor: pointer;
1610
}
1711
</style>
18-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>
19-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.plugin.natural.js"></script>
2012
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/moi.js"></script>
2113
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/select2.min.js"></script>
2214
<script src="{% raw qiita_config.portal_dir %}/static/js/sharing.js"></script>
@@ -302,6 +294,8 @@ <h3 class="gray-msg">Other Studies</h3>
302294
</tr>
303295
</thead>
304296
</table>
297+
</div>
298+
</div>
305299
<!--Abstract Modal-->
306300
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="study-abstract-modal">
307301
<div class="modal-dialog modal-med">

qiita_pet/templates/portals_edit.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{% extends sitebase.html%}
22

33
{%block head%}
4-
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">
54
<style type="text/css">
65
.navlist li
76
{
@@ -11,15 +10,7 @@
1110
.portal-select {
1211
width: 15em;
1312
}
14-
#alert-message {
15-
position: fixed;
16-
top: 55px;
17-
left:30%;
18-
z-index:100;
19-
white-space: nowrap;
20-
}
2113
</style>
22-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>
2314
<script type="text/javascript">
2415
function check_submit(action) {
2516
//disable submit buttons

0 commit comments

Comments
 (0)