X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d10a66b66edc088d33bad52aebd7cac0a6e9ce49..3f4a785775ac28430cc1d1f5968a0ca63d502d92:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index f7d9fe8c2a..2bf781013b 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -161,13 +161,18 @@ class Collection < ArvadosModel # that looks like a Docker image, return it. if loc = Locator.parse(search_term) loc.strip_hints! - coll_match = readable_by(*readers).where(portable_data_hash: loc.to_s).first + coll_match = readable_by(*readers).where(portable_data_hash: loc.to_s).limit(1).first if coll_match and (coll_match.files.size == 1) and (coll_match.files[0][1] =~ /^[0-9A-Fa-f]{64}\.tar$/) - return [find_by_portable_data_hash(loc.to_s).uuid] + return [coll_match.uuid] end end + if search_tag.nil? and (n = search_term.index(":")) + search_tag = search_term[n+1..-1] + search_term = search_term[0..n-1] + end + # Find Collections with matching Docker image repository+tag pairs. matches = base_search. where(link_class: "docker_image_repo+tag", @@ -185,7 +190,8 @@ class Collection < ArvadosModel # anything without; then we use the link's created_at as a tiebreaker. uuid_timestamps = {} matches.find_each do |link| - uuid_timestamps[link.head_uuid] = + c = Collection.find_by_uuid(link.head_uuid) + uuid_timestamps[c.uuid] = [(-link.properties["image_timestamp"].to_datetime.to_i rescue 0), -link.created_at.to_i] end