-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] replace linked_packages with backend_packages
Also saves md5sum for all packages not just links
- Loading branch information
Showing
38 changed files
with
641 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'base64' | ||
require 'event/request' | ||
require 'event' | ||
|
||
include MaintenanceHelper | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class CheckPackageEvent | ||
|
||
attr_accessor :event | ||
attr_accessor :checked_pkgs | ||
|
||
def initialize(event) | ||
self.event = event | ||
self.checked_pkgs = {} | ||
end | ||
|
||
def update_pkg(pkg) | ||
return if self.checked_pkgs.has_key? pkg.id | ||
pkg.update_backendinfo | ||
self.checked_pkgs[pkg.id] = 1 | ||
BackendPackage.where(links_to_id: pkg.id).each do |p| | ||
update_pkg(Package.find(p.package_id)) | ||
end | ||
end | ||
|
||
def perform | ||
pl = event.payload | ||
pkg = Package.find_by_project_and_name(pl['project'], pl['package']) | ||
return unless pkg # there is nothing we can do | ||
# dig into recursion | ||
update_pkg(pkg) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class UpdatePackageMetaJob | ||
|
||
def scan_links | ||
names = Package.distinct(:name).order(:name).pluck(:name) | ||
while !names.empty? do | ||
slice = names.slice!(0, 30) | ||
path = "/search/package/id?match=(" | ||
path += slice.map { |name| "linkinfo/@package='#{CGI.escape(name)}'" }.join("+or+") | ||
path += ")" | ||
answer = Xmlhash.parse(Suse::Backend.get(path).body) | ||
answer.elements('package') do |p| | ||
pkg = Package.find_by_project_and_name(p['project'], p['name']) | ||
# if there is a linkinfo for a package not in database, there can not be a linked_package either | ||
next unless pkg | ||
pkg.update_backendinfo | ||
end | ||
|
||
end | ||
end | ||
|
||
def perform | ||
# first we scan the links so that commits happening | ||
# while the delayed job runs can update our work | ||
scan_links | ||
|
||
Package.order(:name).each do |pkg| | ||
next unless Package.exists?(pkg) | ||
begin | ||
pkg.update_backendinfo | ||
rescue ActiveXML::Transport::Error | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/api/app/models/linked_package.rb → src/api/app/models/backend_package.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.