From 29cf900c9973eea230be5521ab50f62e4d2e15c5 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 14:14:28 +0800 Subject: [PATCH 1/7] =?UTF-8?q?shixun=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_settings_show.html.erb | 1 + db/migrate/20190525060616_modify_exec_time_for_shixun.rb | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 db/migrate/20190525060616_modify_exec_time_for_shixun.rb diff --git a/app/views/shixuns/_settings_show.html.erb b/app/views/shixuns/_settings_show.html.erb index 92417f49..72752703 100644 --- a/app/views/shixuns/_settings_show.html.erb +++ b/app/views/shixuns/_settings_show.html.erb @@ -1,3 +1,4 @@ +
配置 diff --git a/db/migrate/20190525060616_modify_exec_time_for_shixun.rb b/db/migrate/20190525060616_modify_exec_time_for_shixun.rb new file mode 100644 index 00000000..a5602ca8 --- /dev/null +++ b/db/migrate/20190525060616_modify_exec_time_for_shixun.rb @@ -0,0 +1,8 @@ +class ModifyExecTimeForShixun < ActiveRecord::Migration + def up + change_column(:shixuns, :exec_time, :integer, :default => 20) + end + + def down + end +end From a5d2976f172003eaa2b502f3fde5ffb69b7455f1 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:05:04 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 2139715e..f946effa 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -801,6 +801,7 @@ class GamesService # 轮询获取状态 # resubmit是在file_update中生成的,从game_build中传入的 def game_status params, current_user + Rails.logger("sec_key is #{params[:sec_key]}**1") game = Game.find_by_identifier(params[:identifier]) resubmit_identifier = game.resubmit_identifier # 如果没有超时并且正在评测中 @@ -812,6 +813,7 @@ class GamesService return {:running_code_status => running_code_status, :running_code_message => running_code_message} end + Rails.logger("sec_key is #{params[:sec_key]}**2") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") port = params[:port] score = 0 @@ -838,6 +840,7 @@ class GamesService end end + Rails.logger("sec_key is #{params[:sec_key]}**3") # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = game.query_index - 1 # 区分评测过未评测过,未评测过按需求取数据 @@ -854,7 +857,7 @@ class GamesService # 能进入到此处,肯定是已经返回了结果,也就是说outputs中肯定有了数据 - + Rails.logger("sec_key is #{params[:sec_key]}**4") test_sets_count = qurey_test_sets.size # had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test_count = had_test.count @@ -881,6 +884,7 @@ class GamesService web_route = game_challenge.try(:web_route) mirror_name = shixun.mirror_name + Rails.logger("sec_key is #{params[:sec_key]}**5") # 轮询结束,更新评测耗时 e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first if game_status == 0 || game_status == 2 @@ -898,12 +902,14 @@ class GamesService # 实训制作者当前拥有的金币 grade = User.where(:id => game.user_id).pluck(:grade).first + Rails.logger("sec_key is #{params[:sec_key]}**6") # 高性能取上一关、下一关 prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} + Rails.logger("sec_key is #{params[:sec_key]}**7") return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, From bfc78eb673801ab1666e2cfe44741bf378f6259a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:19:26 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index f946effa..f6f9926b 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -801,7 +801,7 @@ class GamesService # 轮询获取状态 # resubmit是在file_update中生成的,从game_build中传入的 def game_status params, current_user - Rails.logger("sec_key is #{params[:sec_key]}**1") + Rails.logger.info("sec_key is #{params[:sec_key]}**1") game = Game.find_by_identifier(params[:identifier]) resubmit_identifier = game.resubmit_identifier # 如果没有超时并且正在评测中 @@ -813,7 +813,7 @@ class GamesService return {:running_code_status => running_code_status, :running_code_message => running_code_message} end - Rails.logger("sec_key is #{params[:sec_key]}**2") + Rails.logger.info("sec_key is #{params[:sec_key]}**2") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") port = params[:port] score = 0 @@ -840,7 +840,7 @@ class GamesService end end - Rails.logger("sec_key is #{params[:sec_key]}**3") + Rails.logger.info("sec_key is #{params[:sec_key]}**3") # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = game.query_index - 1 # 区分评测过未评测过,未评测过按需求取数据 @@ -857,7 +857,7 @@ class GamesService # 能进入到此处,肯定是已经返回了结果,也就是说outputs中肯定有了数据 - Rails.logger("sec_key is #{params[:sec_key]}**4") + Rails.logger.info("sec_key is #{params[:sec_key]}**4") test_sets_count = qurey_test_sets.size # had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test_count = had_test.count @@ -884,7 +884,7 @@ class GamesService web_route = game_challenge.try(:web_route) mirror_name = shixun.mirror_name - Rails.logger("sec_key is #{params[:sec_key]}**5") + Rails.logger.info("sec_key is #{params[:sec_key]}**5") # 轮询结束,更新评测耗时 e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first if game_status == 0 || game_status == 2 @@ -902,14 +902,14 @@ class GamesService # 实训制作者当前拥有的金币 grade = User.where(:id => game.user_id).pluck(:grade).first - Rails.logger("sec_key is #{params[:sec_key]}**6") + Rails.logger.info("sec_key is #{params[:sec_key]}**6") # 高性能取上一关、下一关 prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} - Rails.logger("sec_key is #{params[:sec_key]}**7") + Rails.logger.info("sec_key is #{params[:sec_key]}**7") return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, :position => game_challenge.position, :port => port, :power => power, :record => record, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, From 334d0a800d6a3c3ff1c4bf1ca0d135a0961d7359 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:24:26 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E7=9B=91=E6=8E=A712?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E4=B8=80=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 769481b0..e3ecc2ce 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -853,7 +853,7 @@ class ManagementsController < ApplicationController def evaluate_simple page = params[:page] - @recodes = EvaluateRecord.where("created_at > ?", Time.now - 1.days).reorder("consume_time desc") + @recodes = EvaluateRecord.where("created_at > ?", Time.now - 0.5.days).reorder("consume_time desc") @recodes_count = @recodes.size @record_pages = Paginator.new @recodes_count, 20, page || 1 @offset ||= @record_pages.offset From 768881c1c332a6565f2e64b716154f66c662d394 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:43:02 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E7=94=A8=E6=88=B7=E6=8F=90=E4=BA=A4=E5=92=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index f6f9926b..e413c101 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,7 +371,8 @@ class GamesService end if content != last_content content_modified = 1 - code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => "auto commit") + code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", + :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end # REDO:是否有读写分离的问题 if record.present? From 88fa6989fecf9eba73e09f26fa05a055657615d2 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 15:57:05 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index e413c101..d4fd733a 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,6 +371,9 @@ class GamesService end if content != last_content content_modified = 1 + + Rails.logger.info("@@@@@####{params[:evaluate]}") + Rails.logger.info("@@@@@####{params[:evaluate] == 1 ? "commit by author" : "auto commit" }") code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end From 9ccd8c1c52920bf77c90c2016c7643dc3a8fe5f5 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 25 May 2019 16:00:05 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index d4fd733a..e413c101 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -371,9 +371,6 @@ class GamesService end if content != last_content content_modified = 1 - - Rails.logger.info("@@@@@####{params[:evaluate]}") - Rails.logger.info("@@@@@####{params[:evaluate] == 1 ? "commit by author" : "auto commit" }") code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" )) end