New report showing last login for users, a few bug fixes and some code cleanup for the reports as well.

This commit is contained in:
Greg Von Kuster
2008-12-12 09:43:42 -05:00
parent 16e783267c
commit c58bacce7f
9 changed files with 203 additions and 45 deletions
+1
View File
@@ -299,6 +299,7 @@ assign_mapper( context, History, History.table,
assign_mapper( context, User, User.table,
properties=dict( histories=relation( History, backref="user",
order_by=desc(History.table.c.update_time) ),
galaxy_sessions=relation( GalaxySession, order_by=desc( GalaxySession.table.c.update_time ) ),
stored_workflow_menu_entries=relation( StoredWorkflowMenuEntry, backref="user",
cascade="all, delete-orphan",
collection_class=ordering_list( 'order_index' ) )
+1 -2
View File
@@ -1,6 +1,5 @@
import sys, os, atexit
import sys, config
import galaxy.model
import config
class UniverseApplication( object ):
"""Encapsulates the state of a Universe application"""
@@ -2,7 +2,6 @@
import os, time, logging
# Pieces of Galaxy to make global in every controller
from galaxy import web, util
from Cheetah.Template import Template
log = logging.getLogger( __name__ )
@@ -37,7 +37,15 @@ class System( BaseController ):
deleted_histories_days, msg = self.deleted_histories( **kwd )
elif kwd['action'] == "deleted_datasets":
deleted_datasets_days, msg = self.deleted_datasets( **kwd )
return trans.fill_template( 'system.mako', file_path=file_path, disk_usage=disk_usage, datasets=datasets, file_size_str=file_size_str, userless_histories_days=userless_histories_days, deleted_histories_days=deleted_histories_days, deleted_datasets_days=deleted_datasets_days, msg=msg )
return trans.fill_template( 'system.mako',
file_path=file_path,
disk_usage=disk_usage,
datasets=datasets,
file_size_str=file_size_str,
userless_histories_days=userless_histories_days,
deleted_histories_days=deleted_histories_days,
deleted_datasets_days=deleted_datasets_days,
msg=msg )
def userless_histories( self, **kwd ):
"""The number of userless histories and associated datasets that have not been updated for the specified number of days."""
+31 -14
View File
@@ -1,7 +1,9 @@
from datetime import *
from datetime import datetime, timedelta
from time import strftime
import calendar
from galaxy.webapps.reports.base.controller import *
import galaxy.model
from galaxy.model.orm import *
import pkg_resources
pkg_resources.require( "SQLAlchemy >= 0.4" )
import sqlalchemy as sa
@@ -10,23 +12,20 @@ log = logging.getLogger( __name__ )
class Users( BaseController ):
@web.expose
def index( self, trans, **kwd ):
params = util.Params( kwd )
msg = params.get( 'msg', '' )
return trans.fill_template( 'users.mako', msg=msg )
@web.expose
def registered_users( self, trans, **kwd ):
params = util.Params( kwd )
msg = ''
engine = galaxy.model.mapping.metadata.engine
s = """
SELECT
count(id) AS num_users
FROM
galaxy_user
"""
rows = engine.text( s ).execute().fetchall()
num_users = rows[0].num_users
msg = params.get( 'msg', '' )
num_users = galaxy.model.User.query().count()
return trans.fill_template( 'registered_users.mako', num_users=num_users, msg=msg )
@web.expose
def registered_users_per_month( self, trans, **kwd ):
params = util.Params( kwd )
msg = ''
msg = params.get( 'msg', '' )
q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.User.table.c.create_time ) ).label( 'date' ),
sa.func.count( galaxy.model.User.table.c.id ).label( 'num_users' ) ),
from_obj = [ galaxy.model.User.table ],
@@ -42,7 +41,7 @@ class Users( BaseController ):
@web.expose
def specified_month( self, trans, **kwd ):
params = util.Params( kwd )
msg = ''
msg = params.get( 'msg', '' )
year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) )
start_date = date( year, month, 1 )
end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] )
@@ -70,7 +69,7 @@ class Users( BaseController ):
@web.expose
def specified_date( self, trans, **kwd ):
params = util.Params( kwd )
msg = ''
msg = params.get( 'msg', '' )
year, month, day = map( int, params.get( 'specified_date', datetime.utcnow().strftime( "%Y-%m-%d" ) ).split( "-" ) )
start_date = date( year, month, day )
end_date = start_date + timedelta( days=1 )
@@ -95,3 +94,21 @@ class Users( BaseController ):
day_of_month=day_of_month,
users=users,
msg=msg )
@web.expose
def last_access_date( self, trans, **kwd ):
params = util.Params( kwd )
msg = params.get( 'msg', '' )
not_logged_in_for_days = params.get( 'not_logged_in_for_days', 0 )
if not not_logged_in_for_days:
not_logged_in_for_days = 0
cutoff_time = datetime.utcnow() - timedelta( days=int( not_logged_in_for_days ) )
now = strftime( "%Y-%m-%d %H:%M:%S" )
users = []
for user in galaxy.model.User.query().order_by( galaxy.model.User.table.c.email ).all():
last_galaxy_session = user.galaxy_sessions[ 0 ]
if last_galaxy_session.update_time < cutoff_time:
users.append( ( user.email, last_galaxy_session.update_time.strftime( "%Y-%m-%d" ) ) )
return trans.fill_template( 'users_last_access_date.mako',
users=users,
not_logged_in_for_days=not_logged_in_for_days,
msg=msg )
+85 -26
View File
@@ -1,29 +1,88 @@
<%inherit file="/base_panels.mako"/>
<%def name="main_body()">
## Display the available reports
<div class="body">
<h3 align="center">Galaxy Reports</h3>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">Job Information</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='today_all' )}">Number of jobs today</a> - displays the total number of jobs for today</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='specified_month_all' )}">Number of jobs per day for current month</a> - displays days of the current month with the total number of jobs for each day</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='specified_month_in_error' )}">Number of jobs in error per day for current month</a> - displays days of the current month with the total number of jobs in error for each day</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='all_unfinished' )}">All unfinished jobs</a> - displays jobs that are currently in a "new" state, a "queued" state or a "running" state</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='per_month_all' )}">Number of jobs per month</a> - displays a list of months with the total number of jobs for each month</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='per_month_in_error' )}">Number of jobs in error per month</a> - displays a list of months with the total number of jobs in error for each month</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='per_user' )}">Number of jobs per user</a> - displays users sorted in descending order by the number of jobs they have submitted</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='per_tool' )}">Number of jobs per tool</a> - displays tools sorted in alphabetical order by tool id and the number of jobs created by the tool</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='jobs', action='per_domain' )}">Number of jobs per Internet domain</a> - displays the number of jobs that have been submitted per Internet domain</div></td></tr>
</table>
<br clear="left"/><br/><br/><br/>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">User Information</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='users', action='registered_users' )}">Number of registered users</a> - displays the total number of registered users</div></td></tr>
</table>
<br clear="left"/><br/><br/><br/>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">System Information</div></td></tr>
<tr><td><div class="reportBody"><a href="${h.url_for( controller='system', action='index' )}">Disk space, old histories and datasets</a> - displays history and dataset information including disk space allocation where datasets are stored</div></td></tr>
</table>
</div>
## Display the available reports
<div class="body">
<h3 align="center">Galaxy Reports</h3>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">Job Information</div></td></tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='today_all' )}">Number of jobs today</a> - displays the total number of jobs for today
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='specified_month_all' )}">Number of jobs per day for current month</a> - displays days of the current month with the total number of jobs for each day
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='specified_month_in_error' )}">Number of jobs in error per day for current month</a> - displays days of the current month with the total number of jobs in error for each day
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='all_unfinished' )}">All unfinished jobs</a> - displays jobs that are currently in a "new" state, a "queued" state or a "running" state
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='per_month_all' )}">Number of jobs per month</a> - displays a list of months with the total number of jobs for each month
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='per_month_in_error' )}">Number of jobs in error per month</a> - displays a list of months with the total number of jobs in error for each month
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='per_user' )}">Number of jobs per user</a> - displays users sorted in descending order by the number of jobs they have submitted
</div>
</td>
</tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='jobs', action='per_tool' )}">Number of jobs per tool</a> - displays tools sorted in alphabetical order by tool id and the number of jobs created by the tool
</div>
</td>
</tr>
</table>
<br clear="left"/><br/><br/><br/>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">User Information</div></td></tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='users', action='index' )}">Users</a> - displays information about registered users
</div>
</td>
</tr>
</table>
<br clear="left"/><br/><br/><br/>
<table align="center" width="40%" class="colored">
<tr><td><div class="reportTitle">System Information</div></td></tr>
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='system', action='index' )}">Disk space, old histories and datasets</a> - displays history and dataset information including disk space allocation where datasets are stored
</div>
</td>
</tr>
</table>
</div>
</%def>
@@ -2,7 +2,7 @@
<%def name="main_body()">
<div class="reportBody">
<h3 align="center">All Jobs in Error for ${day_label},&nbsp;${month_label}&nbsp;${day_of_month},&nbsp;${year_label} ( includes jobs deleted before finishing )</h3>
<h3 align="center">All Jobs in Error for ${day_label},&nbsp;${month_label}&nbsp;${day_of_month},&nbsp;${year_label}</h3>
%if msg:
<table align="center" width="70%" class="border" cellpadding="5" cellspacing="5">
<tr><td class="ok_bgr">${msg}</td></tr>
@@ -0,0 +1,29 @@
<%inherit file="/base_panels.mako"/>
<%def name="main_body()">
<h3 align="center">Registered Users</h3>
%if msg:
<table align="center" width="70%" class="border" cellpadding="5" cellspacing="5">
<tr><td class="ok_bgr">${msg}</td></tr>
</table>
%endif
<table align="center" width="40%" class="colored">
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='users', action='registered_users' )}">Registered Users</a> - displays the number of registered users
</div>
</td>
</tr>
</table>
<br clear="left" /><br />
<table align="center" width="40%" class="colored">
<tr>
<td>
<div class="reportBody">
<a href="${h.url_for( controller='users', action='last_access_date' )}">Date of Last Login</a> - displays users sorted by date of last login
</div>
</td>
</tr>
</table>
</%def>
@@ -0,0 +1,46 @@
<%inherit file="/base_panels.mako"/>
<%def name="main_body()">
<h3 align="center">Date of Last Galaxy Login</h3>
<h4 align="center">Listed in descending order by access date ( oldest date first )</h4>
%if msg:
<table align="center" width="70%" class="border" cellpadding="5" cellspacing="5">
<tr><td class="ok_bgr">${msg}</td></tr>
</table>
%endif
<table align="center" width="70%" class="colored" cellpadding="5" cellspacing="5">
<tr>
<td>
<form method="post" controller="users" action="last_access_date">
<p>
Users that have not logged in to Galaxy for
<input type="textfield" value="${not_logged_in_for_days}" size="3" name="not_logged_in_for_days"> days.
&nbsp;<button name="action" value="not_logged_in_for_days">Go</button>
</p>
</form>
</td>
</tr>
</table>
<table align="center" width="70%" class="colored" cellpadding="5" cellspacing="5">
%if users:
<tr class="header">
<td>Email</td>
<td>Date of last Login</td>
</tr>
<% ctr = 0 %>
%for user in users:
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr class="tr">
%endif
<td>${user[0]}</td>
<td>${user[1]}</td>
</tr>
<% ctr += 1 %>
%endfor
%else:
<tr><td>All users have logged in to Galaxy within the past ${not_logged_in_for_days} days</td></tr>
%endif
</table>
</%def>