commit/galaxy-central: Dave Bouvier: Fix for tool shed repository metadata API value mappers when time_last_tested is null for a metadata record.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e1c5eeed1bd6/ Changeset: e1c5eeed1bd6 User: Dave Bouvier Date: 2013-09-11 22:36:52 Summary: Fix for tool shed repository metadata API value mappers when time_last_tested is null for a metadata record. Affected #: 2 files diff -r 18745fd87025971fb7f8a3bc9cd9e54a5f5759de -r e1c5eeed1bd6ba5c66dce308e69e44e6edea920f lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -96,9 +96,6 @@ ] } """ - metadata_value_mapper = { 'id' : trans.security.encode_id, - 'repository_id' : trans.security.encode_id, - 'time_last_tested' : time_ago } repository_value_mapper = { 'id' : trans.security.encode_id, 'user_id' : trans.security.encode_id } # Example URL: http://localhost:9009/api/repositories/get_repository_revision_install_info?name=add_column&owner=test&changeset_revision=3a08cc21466f @@ -123,7 +120,7 @@ if repository_metadata: encoded_repository_metadata_id = trans.security.encode_id( repository_metadata.id ) repository_metadata_dict = repository_metadata.to_dict( view='collection', - value_mapper=metadata_value_mapper ) + value_mapper=self.__get_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', id=encoded_repository_metadata_id ) @@ -194,3 +191,10 @@ log.error( message, exc_info=True ) trans.response.status = 500 return message + + def __get_value_mapper( self, trans, repository_metadata ): + value_mapper = { 'id' : trans.security.encode_id, + 'repository_id' : trans.security.encode_id } + if repository_metadata.time_last_tested is not None: + value_mapper[ 'time_last_tested' ] = time_ago + return value_mapper diff -r 18745fd87025971fb7f8a3bc9cd9e54a5f5759de -r e1c5eeed1bd6ba5c66dce308e69e44e6edea920f lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -72,9 +72,6 @@ GET /api/repository_revisions Displays a collection (list) of repository revisions. """ - value_mapper = { 'id' : trans.security.encode_id, - 'repository_id' : trans.security.encode_id, - 'time_last_tested' : time_ago } # Example URL: http://localhost:9009/api/repository_revisions repository_metadata_dicts = [] # Build up an anded clause list of filters. @@ -124,7 +121,7 @@ .all() for repository_metadata in query: repository_metadata_dict = repository_metadata.to_dict( view='collection', - value_mapper=value_mapper ) + value_mapper=self.__get_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', id=trans.security.encode_id( repository_metadata.id ) ) @@ -144,13 +141,10 @@ :param id: the encoded id of the `RepositoryMetadata` object """ - value_mapper = { 'id' : trans.security.encode_id, - 'repository_id' : trans.security.encode_id, - 'time_last_tested' : time_ago } # Example URL: http://localhost:9009/api/repository_revisions/bb125606ff9ea620 try: repository_metadata = metadata_util.get_repository_metadata_by_id( trans, id ) - repository_metadata_dict = repository_metadata.to_dict( value_mapper=value_mapper ) + repository_metadata_dict = repository_metadata.to_dict( value_mapper=self.__get_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', id=trans.security.encode_id( repository_metadata.id ) ) @@ -167,7 +161,6 @@ PUT /api/repository_revisions/{encoded_repository_metadata_id}/{payload} Updates the value of specified columns of the repository_metadata table based on the key / value pairs in payload. """ - value_mapper = dict( id=trans.security.encode_id, repository_id=trans.security.encode_id, time_last_tested=time_ago ) repository_metadata_id = kwd.get( 'id', None ) try: repository_metadata = metadata_util.get_repository_metadata_by_id( trans, repository_metadata_id ) @@ -188,8 +181,15 @@ log.error( message, exc_info=True ) trans.response.status = 500 return message - repository_metadata_dict = repository_metadata.to_dict( value_mapper=value_mapper ) + repository_metadata_dict = repository_metadata.to_dict( value_mapper=self.__get_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', id=trans.security.encode_id( repository_metadata.id ) ) return repository_metadata_dict + + def __get_value_mapper( self, trans, repository_metadata ): + value_mapper = { 'id' : trans.security.encode_id, + 'repository_id' : trans.security.encode_id } + if repository_metadata.time_last_tested is not None: + value_mapper[ 'time_last_tested' ] = time_ago + return value_mapper 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.
participants (1)
-
commits-noreply@bitbucket.org