2012-12-10 17:01:34 +00:00
|
|
|
module AbfWorker
|
2012-12-29 10:48:19 +00:00
|
|
|
class PublishObserver < AbfWorker::BaseObserver
|
|
|
|
@queue = :publish_observer
|
2012-12-10 17:01:34 +00:00
|
|
|
|
2013-01-17 14:15:03 +00:00
|
|
|
|
2013-01-23 09:42:05 +00:00
|
|
|
def self.perform(options)
|
|
|
|
status = options['status'].to_i
|
|
|
|
return if status == STARTED # do nothing when publication started
|
|
|
|
if options['type'] == 'resign'
|
|
|
|
AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id']
|
|
|
|
else
|
2013-01-23 10:47:32 +00:00
|
|
|
update_rpm_builds options, status
|
2012-12-11 10:42:15 +00:00
|
|
|
end
|
2013-01-23 09:42:05 +00:00
|
|
|
end
|
2012-12-11 10:42:15 +00:00
|
|
|
|
2013-01-23 10:47:32 +00:00
|
|
|
def self.update_rpm_builds(options, status)
|
2013-01-23 09:42:05 +00:00
|
|
|
build_lists = BuildList.where(:id => options['build_list_ids'])
|
|
|
|
build_lists.each do |bl|
|
|
|
|
update_results(bl, options)
|
|
|
|
case status
|
|
|
|
when COMPLETED
|
|
|
|
bl.published
|
|
|
|
AbfWorker::BuildListsPublishTaskManager.cleanup_completed options['projects_for_cleanup']
|
|
|
|
when FAILED, CANCELED
|
|
|
|
bl.fail_publish
|
|
|
|
AbfWorker::BuildListsPublishTaskManager.cleanup_failed options['projects_for_cleanup']
|
2013-01-17 14:15:03 +00:00
|
|
|
end
|
2013-01-23 09:42:05 +00:00
|
|
|
AbfWorker::BuildListsPublishTaskManager.unlock_build_list bl
|
2013-01-17 14:15:03 +00:00
|
|
|
end
|
2013-01-23 09:42:05 +00:00
|
|
|
bl = build_lists.first || BuildList.find(options['id'])
|
|
|
|
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform bl
|
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
|
|
|
protected
|
2013-01-17 14:15:03 +00:00
|
|
|
|
|
|
|
def update_results(subject, options)
|
|
|
|
results = (subject.results || []).
|
|
|
|
select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-worker.*\.log$/ }
|
|
|
|
results |= options['results']
|
|
|
|
sort_results_and_save(subject, results)
|
|
|
|
end
|
2012-12-12 12:32:47 +00:00
|
|
|
end
|
2012-12-10 17:01:34 +00:00
|
|
|
end
|
|
|
|
end
|