#245: rescue RecordNotUnique error
This commit is contained in:
parent
e38bfa797f
commit
5a660ded4e
|
@ -14,7 +14,11 @@ class BuildListObserver < ActiveRecord::Observer
|
|||
|
||||
if record.status == BuildList::SUCCESS
|
||||
# Update project average build time
|
||||
begin
|
||||
statistic = record.project.project_statistics.find_or_create_by_arch_id(record.arch_id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
build_count = statistic.build_count
|
||||
new_av_time = ( statistic.average_build_time * build_count + record.duration ) / ( build_count + 1 )
|
||||
statistic.update_attributes(:average_build_time => new_av_time, :build_count => build_count)
|
||||
|
|
Loading…
Reference in New Issue