|
|
|
@ -67,15 +67,11 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
## 排序参数
|
|
|
|
|
bsort = params[:sort] || 'desc'
|
|
|
|
|
case params[:order_by] || 'publish_time'
|
|
|
|
|
when 'new'
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.created_at #{bsort}")
|
|
|
|
|
case params[:order_by] || 'new'
|
|
|
|
|
when 'hot'
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.myshixuns_count #{bsort}")
|
|
|
|
|
when 'mine'
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.created_at #{bsort}")
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.public = 2 desc, shixuns.myshixuns_count #{bsort}")
|
|
|
|
|
else
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.publish_time #{bsort}")
|
|
|
|
|
@shixuns = @shixuns.order("shixuns.public = 2 desc, shixuns.publish_time #{bsort}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 用id计数会快10+MS左右,对于搜索的内容随着数据的增加,性能会提升一些。
|
|
|
|
@ -265,7 +261,12 @@ class ShixunsController < ApplicationController
|
|
|
|
|
project_fork(@new_shixun, @repo_path, current_user.login)
|
|
|
|
|
|
|
|
|
|
ShixunMember.create!(:user_id => User.current.id, :shixun_id => @new_shixun.try(:id), :role => 1)
|
|
|
|
|
|
|
|
|
|
# 如果是jupyter,先创建一个目录,为了挂载(因为后续数据集,开启Pod后环境在没销毁前,你上传数据集是挂载不上目录的,因此要先创建目录,方便中间层挂载)
|
|
|
|
|
if @new_shixun.is_jupyter?
|
|
|
|
|
folder = EduSetting.get('shixun_folder')
|
|
|
|
|
path = "#{folder}/#{@new_shixun.identifier}"
|
|
|
|
|
FileUtils.mkdir_p(path, :mode => 0777) unless File.directory?(path)
|
|
|
|
|
end
|
|
|
|
|
# 同步复制关卡
|
|
|
|
|
if @shixun.challenges.present?
|
|
|
|
|
@shixun.challenges.each do |challenge|
|
|
|
|
@ -408,16 +409,14 @@ class ShixunsController < ApplicationController
|
|
|
|
|
smr.update_attributes(service)
|
|
|
|
|
end
|
|
|
|
|
# 添加第二仓库(管理员权限)
|
|
|
|
|
if current_user.admin_or_business?
|
|
|
|
|
if params[:is_secret_repository]
|
|
|
|
|
add_secret_repository if @shixun.shixun_secret_repository.blank?
|
|
|
|
|
else
|
|
|
|
|
# 如果有仓库,就要删
|
|
|
|
|
if @shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
@shixun.shixun_secret_repository.lock!
|
|
|
|
|
GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path)
|
|
|
|
|
@shixun.shixun_secret_repository.destroy
|
|
|
|
|
end
|
|
|
|
|
if params[:is_secret_repository]
|
|
|
|
|
add_secret_repository if @shixun.shixun_secret_repository.blank?
|
|
|
|
|
else
|
|
|
|
|
# 如果有仓库,就要删
|
|
|
|
|
if @shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
@shixun.shixun_secret_repository.lock!
|
|
|
|
|
GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path)
|
|
|
|
|
@shixun.shixun_secret_repository.destroy
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -463,7 +462,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
limit = params[:limit] || 10
|
|
|
|
|
data_sets = @shixun.data_sets
|
|
|
|
|
@data_count = data_sets.count
|
|
|
|
|
@data_sets= data_sets.page(page).per(limit)
|
|
|
|
|
@data_sets= data_sets.order("created_on desc").page(page).per(limit)
|
|
|
|
|
@absolute_folder = edu_setting('shixun_folder')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -758,7 +757,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
else
|
|
|
|
|
commit = GitService.commits(repo_path: @repo_path).try(:first)
|
|
|
|
|
uid_logger("First comit########{commit}")
|
|
|
|
|
tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
|
|
|
|
|
tip_exception("开启挑战前,请先在Jupyter中填写内容") if commit.blank?
|
|
|
|
|
commit_id = commit["id"]
|
|
|
|
|
cloud_bridge = edu_setting('cloud_bridge')
|
|
|
|
|
myshixun_identifier = generate_identifier Myshixun, 10
|
|
|
|
@ -776,7 +775,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("实训云平台繁忙(繁忙等级:81)")
|
|
|
|
|
tip_exception("#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|