Skip to content

Commit

Permalink
[api] tune maintainer handling
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jul 3, 2014
1 parent 06cc793 commit 1476d72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/api/app/models/repository.rb
Expand Up @@ -103,21 +103,25 @@ def update_binary_releases_via_json(json, time = Time.now)
entry.obsolete_time = Time.now
entry.save!
oldlist.delete(entry)
hash['operation'] = "modified" # new entry will get "modified" instead of "added"
hash[:operation] = "modified" # new entry will get "modified" instead of "added"
end

# complete hash for new entry
hash['binary_releasetime'] = time
hash['binary_disturl'] = binary["disturl"]
hash['binary_supportstatus'] = binary["supportstatus"]
hash[:binary_releasetime] = time
hash[:binary_disturl] = binary["disturl"]
hash[:binary_supportstatus] = binary["supportstatus"]

if binary["project"] and rp = Package.find_by_project_and_name(binary["project"], binary["package"])
hash['release_package_id'] = rp.id
hash[:release_package_id] = rp.id
end
if binary["patchinforef"]
pi = Patchinfo.new(Suse::Backend.get("/source/#{binary["patchinforef"]}/_patchinfo").body)
begin
pi = Patchinfo.new(Suse::Backend.get("/source/#{binary["patchinforef"]}/_patchinfo").body)
rescue ActiveXML::Transport::NotFoundError
# patchinfo disappeared meanwhile
end
# no database object on purpose, since it must also work for historic releases...
hash['binary_maintainer'] = pi.to_hash['packager'] if pi and pi.to_hash['packager']
hash[:binary_maintainer] = pi.to_hash['packager'] if pi and pi.to_hash['packager']
end

# new entry, also for modified binaries.
Expand Down
2 changes: 2 additions & 0 deletions src/api/test/unit/binary_release.rb
Expand Up @@ -25,6 +25,7 @@ def test_create_and_find_entries
:binary_release => "2.3",
:binary_arch => "noarch",
:binary_supportstatus => "unsupported",
:binary_maintainer => "tom",
)
sbr = BinaryRelease.find_by_repo_and_name( r, "package" )
assert_equal sbr.first, br
Expand All @@ -33,6 +34,7 @@ def test_create_and_find_entries
assert_equal sbr.first.binary_release, "2.3"
assert_equal sbr.first.binary_arch, "noarch"
assert_equal sbr.first.binary_supportstatus, "unsupported"
assert_equal sbr.first.binary_maintainer, "tom"
assert_equal sbr.first.binary_releasetime, Time.now
sbr = BinaryRelease.find_by_repo_and_name( r, "package" )
assert_equal sbr.first, br
Expand Down
1 change: 1 addition & 0 deletions src/api/test/unit/code_quality_test.rb
Expand Up @@ -97,6 +97,7 @@ def setup
'Project#update_one_repository_without_path' => 150.7,
'PublicController#binary_packages' => 131.24,
'Repository#cleanup_before_destroy' => 85.53,
'Repository#update_binary_releases_via_json' => 86.1,
'RequestController#render_request_collection' => 92.82,
'SearchController#find_attribute' => 97.33,
'SourceController#project_command_copy' => 140.04,
Expand Down

0 comments on commit 1476d72

Please sign in to comment.