1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/206055969b7c/ Changeset: 206055969b7c User: carlfeberhard Date: 2013-12-11 17:55:59 Summary: UsesHistoryMixin: add get_user_histories; use in History API, index Affected #: 2 files diff -r a831eb375268fcf80479f7bf325ec7d8a757582c -r 206055969b7cedcbfcac36c19428b9547cd5cb5d lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -30,7 +30,7 @@ from galaxy.web.form_builder import AddressField, CheckboxField, SelectField, TextArea, TextField from galaxy.web.form_builder import build_select_field, HistoryField, PasswordField, WorkflowField, WorkflowMappingField from galaxy.workflow.modules import module_factory -from galaxy.model.orm import eagerload, eagerload_all +from galaxy.model.orm import eagerload, eagerload_all, desc from galaxy.security.validate_user_input import validate_publicname from galaxy.util.sanitize_html import sanitize_html from galaxy.model.item_attrs import Dictifiable @@ -341,6 +341,28 @@ history = self.security_check( trans, history, check_ownership, check_accessible ) return history + def get_user_histories( self, trans, user=None, include_deleted=False, only_deleted=False ): + """ + Get all the histories for a given user (defaulting to `trans.user`) + ordered by update time and filtered on whether they've been deleted. + """ + # handle default and/or anonymous user (which still may not have a history yet) + user = user or trans.user + if not user: + current_history = trans.get_history() + return [ current_history ] if current_history else [] + + history_model = trans.model.History + query = ( trans.sa_session.query( history_model ) + .filter( history_model.user == user ) + .order_by( desc( history_model.table.c.update_time ) ) ) + if only_deleted: + query = query.filter( history_model.deleted == True ) + elif not include_deleted: + query = query.filter( history_model.deleted == False ) + + return query.all() + def get_history_datasets( self, trans, history, show_deleted=False, show_hidden=False, show_purged=False ): """ Returns history's datasets. """ query = trans.sa_session.query( trans.model.HistoryDatasetAssociation ) \ diff -r a831eb375268fcf80479f7bf325ec7d8a757582c -r 206055969b7cedcbfcac36c19428b9547cd5cb5d lib/galaxy/webapps/galaxy/api/histories.py --- a/lib/galaxy/webapps/galaxy/api/histories.py +++ b/lib/galaxy/webapps/galaxy/api/histories.py @@ -41,11 +41,9 @@ deleted = string_as_bool( deleted ) try: if trans.user: - query = ( trans.sa_session.query( trans.app.model.History ) - .filter_by( user=trans.user, deleted=deleted ) - .order_by( desc( trans.app.model.History.table.c.update_time ) ) - .all() ) - for history in query: + histories = self.get_user_histories( trans, user=trans.user, only_deleted=deleted ) + #for history in query: + for history in histories: item = history.to_dict(value_mapper={'id':trans.security.encode_id}) item['url'] = url_for( 'history', id=trans.security.encode_id( history.id ) ) rval.append( item ) @@ -58,6 +56,7 @@ rval.append(item) except Exception, e: + raise rval = "Error in history API" log.error( rval + ": %s" % str(e) ) trans.response.status = 500 Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.