From 6fa7223e4b77306444c0ba7c1b56ede115721bce Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:16:22 +0800 Subject: [PATCH 1/6] git password --- app/controllers/gits_controller.rb | 1 + lib/gitcheck/myshixun_update.txt | 0 lib/gitcheck/readme_test.txt | 51 ++++++++++++++++++++++++++++++ lib/gitcheck/shixun_update.txt | 0 lib/tasks/git_check.rake | 16 ++++++++++ 5 files changed, 68 insertions(+) create mode 100644 lib/gitcheck/myshixun_update.txt create mode 100644 lib/gitcheck/readme_test.txt create mode 100644 lib/gitcheck/shixun_update.txt create mode 100644 lib/tasks/git_check.rake diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index 60a551e7b..d1e3912b6 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -17,6 +17,7 @@ class GitsController < ApplicationController input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() uid_logger("git start auth: input_username is #{input_username}") + uid_logger("git start auth: password is #{input_password}") # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip diff --git a/lib/gitcheck/myshixun_update.txt b/lib/gitcheck/myshixun_update.txt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/gitcheck/readme_test.txt b/lib/gitcheck/readme_test.txt new file mode 100644 index 000000000..03f757f18 --- /dev/null +++ b/lib/gitcheck/readme_test.txt @@ -0,0 +1,51 @@ +# 新版Git测试说明 +统一: +参考实训:http://47.96.87.25:48080/shixuns/ca9fvobr/repository +请求方式:POST +参数{repo_path: "educoder/ca9fvobr.git"} +公共方法: +['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', + 'file_content', 'commits'] + +1、仓库目录接口 + 测试方法:模拟1000个用户同时去访问接口,访问方式 + http://121.199.19.206:9000/api/file_tree + 参数: + {repo_path: "educoder/ca9fvobr.git", path: ''} // 如:{path: 'step1'} + +2、创建版本库 + 访问地址:http://121.199.19.206:9000/api/add_repository + 参数: + {repo_path: 比如:"Hjqreturn/aaass1.git"} + +3、fork版本库 + http://121.199.19.206:9000/api/fork_repository + 参数: + {repo_path: 'Hjqreturn/aaass1.git', fork_repository_path: 'educoder/ca9fvobr.git'} + 说明:fork_repository_path是源项目的repo_path, repo_path是新项目的 + + +4、更新文件 + 测试方法: + 1、更新同一个文件,并发量可以不用很大,可以用同一个用户并发10-100 + 2、更新不同的文件:可以依据创建的版本库去更新 + 访问地址:http://121.199.19.206:9000/api/update_file + 参数: + {repo_path: "educoder/ca9fvobr.git", + file_path: 'step1/main.py', + message: 'commit by test', + content: 'afdjadsjfj1111', + author_name: 'guange', + author_email: '8863824@gmil.com'} + +5、获取文件内容 + 访问地址:http://121.199.19.206:9000/api/file_content + 参数: + {repo_path: "educoder/ca9fvobr.git", file_path: 'step1/main.py',} + +6、获取提交记录 + 访问地址:http://121.199.19.206:9000/api/commits + 参数: + {repo_path: 比如:"educoder/ca9fvobr.git"} + + diff --git a/lib/gitcheck/shixun_update.txt b/lib/gitcheck/shixun_update.txt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/tasks/git_check.rake b/lib/tasks/git_check.rake new file mode 100644 index 000000000..64f8be91b --- /dev/null +++ b/lib/tasks/git_check.rake @@ -0,0 +1,16 @@ +namespace :git do + desc "检测是否TPM是否需要更新" + task :shixun_check_update => :environment do + + end + + desc "检测版本库是否有异常" + task :myshixuns_check_update => :environment do + + end + + + task :check => :environment do + + end +end From 8fbad4aaf3d9977f18c4bbdad839dd3025f7583e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:24:37 +0800 Subject: [PATCH 2/6] git service add log --- app/controllers/gits_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index d1e3912b6..c3fa30270 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -16,8 +16,8 @@ class GitsController < ApplicationController username_password = Base64.decode64(request.env["HTTP_AUTHORIZATION"].split(" ")[1]) input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() - uid_logger("git start auth: input_username is #{input_username}") - uid_logger("git start auth: password is #{input_password}") + uid_logger("git start auth: input_username is 55#{input_username}55") + uid_logger("git start auth: password is 66#{input_password}66") # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip @@ -28,7 +28,7 @@ class GitsController < ApplicationController # 如果用户名密码错误 if !system_user.check_password?(input_password) - uid_logger_error("git start: password is wrong") + uid_logger_error("git start: password is wrong#77#{input_password}77") result = false else git_url = params["url"] From b37c4db7702d2f25e95d73e53a23aafb3e59dd62 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 09:31:53 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 25 +++++++++---------- app/models/myshixun.rb | 1 - ...625012548_add_index_for_evaluate_record.rb | 6 +++++ 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20190625012548_add_index_for_evaluate_record.rb diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f1b4306ff..0ac7e9835 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -484,16 +484,15 @@ class ShixunsController < ApplicationController # 中间需要一个过渡动画 # TODO: 第一次开启实训都会去判断是否是纯选择题类型,感觉做成在创建关卡的时候就判断该实训是否是纯选择题更加合适 def shixun_exec - current_myshixun = @shixun.current_myshixun(current_user.id) - if @shixun.opening_time.present? && @shixun.opening_time > Time.now && current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") end - + current_myshixun = @shixun.current_myshixun(current_user.id) if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") - if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort + if current_myshixun.games.count != @shixun.challenges_count || + current_myshixun.games.reorder(:challenge_id).pluck(:challenge_id) != @shixun.challenges.reorder(:id).pluck(:id) + uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end @@ -517,7 +516,7 @@ class ShixunsController < ApplicationController ActiveRecord::Base.transaction do begin - cloud_bridge = edu_setting('cloud_bridge') + #cloud_bridge = edu_setting('cloud_bridge') myshixun_identifier = generate_identifier Myshixun, 10 myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier, modify_time: @shixun.modify_time, reset_time: @shixun.reset_time, @@ -529,12 +528,12 @@ class ShixunsController < ApplicationController # fork仓库 project_fork(myshixun, @repo_path, current_user.login) - rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) - uid_logger("start openGameInstance") - uri = "#{cloud_bridge}/bridge/game/openGameInstance" - logger.info("end openGameInstance") - params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} - uid_logger("openGameInstance params is #{params}") + #rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) + #uid_logger("start openGameInstance") + #uri = "#{cloud_bridge}/bridge/game/openGameInstance" + #logger.info("end openGameInstance") + #params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} + #uid_logger("openGameInstance params is #{params}") # res = interface_post uri, params, 83, "实训云平台繁忙(繁忙等级:83)" end # 其它创建关卡等操作 @@ -547,7 +546,7 @@ class ShixunsController < ApplicationController :open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time) end - # REDO:开启实训时更新关联作品的状态 + # REDO:开启实训时更新关联作品的状态-> TODO:这个可以异步。 HomeworksService.new.update_myshixun_work_status myshixun @current_task = myshixun.current_task diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..53f06293c 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,7 +56,6 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? if self.status == 1 diff --git a/db/migrate/20190625012548_add_index_for_evaluate_record.rb b/db/migrate/20190625012548_add_index_for_evaluate_record.rb new file mode 100644 index 000000000..d67e33b1e --- /dev/null +++ b/db/migrate/20190625012548_add_index_for_evaluate_record.rb @@ -0,0 +1,6 @@ +class AddIndexForEvaluateRecord < ActiveRecord::Migration[5.2] + def change + # 增加evalute_records的索引,提高查询效率 + add_index :evaluate_records, :game_id + end +end From 9b57aa80ba76fc7fbf8c1cb12c0b82a0aa454201 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:40:47 +0800 Subject: [PATCH 4/6] git auth --- app/controllers/gits_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index c3fa30270..f00245190 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -16,8 +16,8 @@ class GitsController < ApplicationController username_password = Base64.decode64(request.env["HTTP_AUTHORIZATION"].split(" ")[1]) input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() - uid_logger("git start auth: input_username is 55#{input_username}55") - uid_logger("git start auth: password is 66#{input_password}66") + uid_logger("git start auth: input_username is #{input_username}") + # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip @@ -28,7 +28,7 @@ class GitsController < ApplicationController # 如果用户名密码错误 if !system_user.check_password?(input_password) - uid_logger_error("git start: password is wrong#77#{input_password}77") + uid_logger_error("git start: password is wrong") result = false else git_url = params["url"] @@ -44,12 +44,13 @@ class GitsController < ApplicationController if system_user.present? && system_user.manager_of_shixun?(shixun) result = true else - logger.info("git411 start") + uid_logger_error("gituser is not shixun manager") result = false end else - render :json => { :status => 404 } - result = false + uid_logger_error("shixun is not exist") + # result = false + result = true # 为了测试跳出 end end end From 647a618ee62095ef0045e2553d02c161419fed13 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:10:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0ac7e9835..40879dc08 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -546,7 +546,8 @@ class ShixunsController < ApplicationController :open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time) end - # REDO:开启实训时更新关联作品的状态-> TODO:这个可以异步。 + # REDO:开启实训时更新关联作品的状态 + # TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做 HomeworksService.new.update_myshixun_work_status myshixun @current_task = myshixun.current_task From 93203edade8ac3fcccd18ca69c60ad314b55effc Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:51:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9C=89=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 40879dc08..360732120 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -47,7 +47,7 @@ class ShixunsController < ApplicationController where("challenge_tags.name like '%#{keyword}%' or challenges.subject like '%#{keyword}%' or concat(lastname, firstname) like '%#{keyword}%' - or shixuns.name like '%#{keyword.split(" ").join("%")}%'") + or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct end ## 筛选 状态