game status问题

This commit is contained in:
huang 2017-06-14 09:55:57 +08:00
parent 4b380bd126
commit 42f77281df
2 changed files with 43 additions and 1 deletions

View File

@ -78,8 +78,9 @@ class MyshixunsController < ApplicationController
if !resubmit.blank?
game.update_attributes(:retry_status => 2, :resubmit_identifier => resubmit)
else
game.update_attributes(:status => 2, :end_time => Time.now)
unless game.answer_open?
game.update_attributes(:status => 2, :final_score => challenge.score, :end_time => Time.now)
game.update_attribute(:final_score, challenge.score)
end
end
else

View File

@ -0,0 +1,41 @@
namespace :jenkins_mult do
namespace :myshixun do
desc "ping ce"
task :game_build => :environment do
100.times do
puts "start"
myshixun_ids =
games = Game.where(:shixun)
game = Game.find_by_identifier('lzwg7ute3ki5')
myshixun = game.myshixun
game_challenge = game.challenge
rep_identify = Repository.where(:myshixun_id => myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
gitlab_address = Redmine::Configuration['gitlab_address']
gitUrl = gitlab_address.to_s+"/"+myshixun.owner.to_s+"/"+ rep_identify + "."+"git"
gitUrl = Base64.encode64(gitUrl)
taskId = game.id
jobName = "myshixun_#{myshixun.id}"
if game.status == 2
game.update_attribute(:status, 0)
end
# 过关后重评不更新状态
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
step = game_challenge.try(:position)
params = {:jobNameForInstance => "#{jobName}", :buildID => "#{taskId}", :step => "#{step}", :instanceGitURL => "#{gitUrl}", :instanceChallenge => "#{step}", :resubmit => nil}
uri = URI("#{jenkins_shixuns}/jenkins-exec/api/buildJobForInstance")
puts("post data time is #{Time.now}")
res = Net::HTTP.post_form(uri, params).body
res = JSON.parse(res)
puts("post data end time is #{Time.now}")
if (res && res['code'] != 0)
puts("error")
puts("current time is #{Time.now}")
end
puts("game over")
puts("waiting for 120s")
sleep(120);
end
end
end
end