diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index 4bac9f6d7..0bfd5aebd 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -1,10 +1,6 @@ module AbfWorker class IsoWorkerObserver - BUILD_COMPLETED = 0 - BUILD_FAILED = 1 - BUILD_PENDING = 2 - BUILD_STARTED = 3 - BUILD_CANCELED = 4 + extend AbfWorker::ObserverHelper @queue = :iso_worker_observer def self.perform(options) diff --git a/lib/abf_worker/observer_helper.rb b/lib/abf_worker/observer_helper.rb new file mode 100644 index 000000000..31ac8554a --- /dev/null +++ b/lib/abf_worker/observer_helper.rb @@ -0,0 +1,9 @@ +module AbfWorker + module ObserverHelper + BUILD_COMPLETED = 0 + BUILD_FAILED = 1 + BUILD_PENDING = 2 + BUILD_STARTED = 3 + BUILD_CANCELED = 4 + end +end \ No newline at end of file diff --git a/lib/abf_worker/publish_build_list_container_observer.rb b/lib/abf_worker/publish_build_list_container_observer.rb index 5cfc449ce..6fc70272f 100644 --- a/lib/abf_worker/publish_build_list_container_observer.rb +++ b/lib/abf_worker/publish_build_list_container_observer.rb @@ -1,9 +1,33 @@ module AbfWorker class PublishBuildListContainerObserver + extend AbfWorker::ObserverHelper @queue = :publish_build_list_container_observer def self.perform(options) - # TODO: ... + bl = BuildList.find options['id'] + status = options['status'].to_i + case status + when BUILD_COMPLETED + bl.published + update_results(bl, options) + when BUILD_FAILED + bl.fail_publish + update_results(bl, options) + when BUILD_CANCELED + bl.fail_publish + update_results(bl, options) + end + end + + class << self + protected + + def update_results(bl, options) + results = bl.results + options['results'] + bl.results = results.sort_by{ |r| r['file_name'] } + bl.save! + end + end end diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 647a45051..8981c4d11 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -1,11 +1,6 @@ module AbfWorker class RpmWorkerObserver - BUILD_COMPLETED = 0 - BUILD_FAILED = 1 - BUILD_PENDING = 2 - BUILD_STARTED = 3 - BUILD_CANCELED = 4 - + extend AbfWorker::ObserverHelper @queue = :rpm_worker_observer def self.perform(options)