From: donghee yang Date: Wed, 17 Apr 2013 01:18:37 +0000 (+0900) Subject: [Title] Fixed a bug that end time of job is incorrect X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c979c4501eb0c00e997dcf060a4a47a89c57ab1;p=sdk%2Ftools%2Fsdk-build.git [Title] Fixed a bug that end time of job is incorrect --- diff --git a/src/build_server/CommonJob.rb b/src/build_server/CommonJob.rb index 2bea783..7d4af20 100644 --- a/src/build_server/CommonJob.rb +++ b/src/build_server/CommonJob.rb @@ -62,7 +62,7 @@ class CommonJob @locked = false @log = nil - @start_time = Time.now + @start_time = nil @end_time = nil @thread = nil @sub_pid = 0 @@ -273,11 +273,11 @@ class CommonJob # save to db public - def save(db, now) - + def save(db) + now = @server.db_now prj_id = @project.nil? ? "NULL" : @project.get_project_id() if @id.nil? then - start_time = @start_time.strftime("%F %T") + @start_time = Time.now os_id = BuildServer.get_supported_os_id(db, @os) dist_id = PackageDistribution.get_distribution_id(db, get_distribution_name()) parent_id = @parent.nil? ? "NULL" : @parent.id @@ -293,8 +293,10 @@ class CommonJob db.do "UPDATE jobs SET source_id=#{source_id} WHERE id=#{@id}" end db.do "UPDATE jobs SET status='#{@status}',remote_build_server_id=#{remote_bs_id} WHERE id=#{@id}" - if @status == "FINISHED" or @status == "ERROR" or @status == "CANCELED" then - @end_time = Time.now.strftime("%F %T") + if @end_time.nil? and + @status == "FINISHED" or @status == "ERROR" or @status == "CANCELED" then + + @end_time = Time.now db.do "UPDATE jobs SET end_time=#{now} WHERE id=#{@id}" end end diff --git a/src/build_server/JobManager.rb b/src/build_server/JobManager.rb index 3ad27d8..68fb7e6 100644 --- a/src/build_server/JobManager.rb +++ b/src/build_server/JobManager.rb @@ -501,11 +501,10 @@ class JobManager # if transferred job, no need to save if job.is_transferred? then return true end - now = @server.db_now result = @server.get_db_connection() do |db| - job.save(db, now) + job.save(db) job.sub_jobs.each do |j| - j.save(db, now) + j.save(db) end end