Skip to content

Commit

Permalink
Added the ability to sort by id and job number on the jobs per tool page
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Bouchard committed Jun 1, 2015
1 parent 273bae4 commit 0369161
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
19 changes: 17 additions & 2 deletions lib/galaxy/webapps/reports/controllers/jobs.py
Expand Up @@ -407,6 +407,20 @@ def per_tool( self, trans, **kwd ):

params = util.Params( kwd )
monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' )

sort_id = kwd.get('sort')
order = kwd.get('order')

if sort_id == "default":
sort_id = "tool_id"

if order == "default":
order = "asc"
_order = sa.asc( sort_id )
elif order == "asc":
_order = sa.asc( sort_id )
elif order == "desc":
_order = sa.desc( sort_id )

# In case we don't know which is the monitor user we will query for all jobs
monitor_user_id = get_monitor_id( trans, monitor_email )
Expand All @@ -417,15 +431,16 @@ def per_tool( self, trans, **kwd ):
whereclause=model.Job.table.c.user_id != monitor_user_id,
from_obj=[ model.Job.table ],
group_by=[ 'tool_id' ],
order_by=[ 'tool_id' ] )
order_by=[ _order ] )
for row in q.execute():
jobs.append( ( row.tool_id,
row.total_jobs ) )
return trans.fill_template( '/webapps/reports/jobs_per_tool.mako',
sort=sort_id,
order=order,
jobs=jobs,
message=message,
is_user_jobs_only=monitor_user_id )

@web.expose
def tool_per_month( self, trans, **kwd ):
message = ''
Expand Down
2 changes: 1 addition & 1 deletion templates/webapps/reports/index.mako
Expand Up @@ -52,7 +52,7 @@
<div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='jobs', action='per_month_all' )}">Jobs per month</a></div>
<div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='jobs', action='per_month_in_error' )}">Jobs in error per month</a></div>
<div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='jobs', action='per_user' )}">Jobs per user</a></div>
<div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='jobs', action='per_tool' )}">Jobs per tool</a></div>
<div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='jobs', action='per_tool', sort='default', order='default' )}">Jobs per tool</a></div>
</div>
</div>
<div class="toolSectionPad"></div>
Expand Down
35 changes: 32 additions & 3 deletions templates/webapps/reports/jobs_per_tool.mako
Expand Up @@ -5,6 +5,34 @@
${render_msg( message, 'done' )}
%endif

<%
up_arrow = "&#x2191;"
down_arrow = "&#x2193;"
id_order = order
total_order = order
id_arrow = " "
total_arrow = " "
if sort == "tool_id":
if id_order == "asc":
id_arrow += down_arrow
id_order = "desc"
else:
id_arrow += up_arrow
id_order = "asc"
pass
elif sort == "total_jobs":
if total_order == "asc":
total_arrow += down_arrow
total_order = "desc"
else:
total_arrow += up_arrow
total_order = "asc"
pass
%>

<!--jobs_per_tool.mako-->
<div class="toolForm">
<div class="toolFormBody">
<h4 align="center">Jobs Per Tool</h4>
Expand All @@ -14,11 +42,11 @@
<tr><td colspan="2">There are no jobs.</td></tr>
%else:
<tr class="header">
<td>Tool id</td>
<td><a href="${h.url_for( controller='jobs', action='per_tool', sort='tool_id', order=id_order )}">Tool id</a><span>${id_arrow}</span><td>
%if is_user_jobs_only:
<td>User Jobs</td>
<td><a href="${h.url_for( controller='jobs', action='per_tool', sort='total_jobs', order=total_order )}">User Jobs</a><span>${total_arrow}</span></td>
%else:
<td>User + Monitor Jobs</td>
<td><a href="${h.url_for( controller='jobs', action='per_tool', sort='total_jobs', order=total_order )}">User + Monitor Jobs</a><span>${total_arrow}</span></td>
%endif
</tr>
<% ctr = 0 %>
Expand All @@ -37,3 +65,4 @@
</table>
</div>
</div>
<!--End jobs_per_tool.mako-->

0 comments on commit 0369161

Please sign in to comment.