@locked = false
@log = nil
- @start_time = Time.now
+ @start_time = nil
@end_time = nil
@thread = nil
@sub_pid = 0
# 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
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
# 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