[Title] Fixed a bug that end time of job is incorrect
authordonghee yang <donghee.yang@samsung.com>
Wed, 17 Apr 2013 01:18:37 +0000 (10:18 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Wed, 17 Apr 2013 01:18:37 +0000 (10:18 +0900)
src/build_server/CommonJob.rb
src/build_server/JobManager.rb

index 2bea7832925bcd67a5746531ab2490090e8910fc..7d4af202a54aafd8196e5c4a53428b17649671b9 100644 (file)
@@ -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
index 3ad27d84c59943219ae5cc6978eaa7fbb56a04bb..68fb7e66127cc9731f84180a7f56ee7c06e9ab7e 100644 (file)
@@ -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