Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
daiao 5 years ago
commit eb8e7c6fed

1
.gitignore vendored

@ -44,6 +44,7 @@
/config/secrets.yml /config/secrets.yml
/config/redis.yml /config/redis.yml
/config/elasticsearch.yml
public/upload.html public/upload.html
/config/configuration.yml /config/configuration.yml

@ -90,4 +90,4 @@ gem 'sinatra'
gem 'bulk_insert' gem 'bulk_insert'
# elasticsearch # elasticsearch
# gem 'searchkick' gem 'searchkick'

@ -90,6 +90,14 @@ GEM
connection_pool (2.2.2) connection_pool (2.2.2)
crass (1.0.4) crass (1.0.4)
diff-lcs (1.3) diff-lcs (1.3)
elasticsearch (7.2.0)
elasticsearch-api (= 7.2.0)
elasticsearch-transport (= 7.2.0)
elasticsearch-api (7.2.0)
multi_json
elasticsearch-transport (7.2.0)
faraday
multi_json
erubi (1.7.1) erubi (1.7.1)
execjs (2.7.0) execjs (2.7.0)
faraday (0.15.4) faraday (0.15.4)
@ -100,6 +108,7 @@ GEM
grape-entity (0.7.1) grape-entity (0.7.1)
activesupport (>= 4.0) activesupport (>= 4.0)
multi_json (>= 1.3.2) multi_json (>= 1.3.2)
hashie (3.6.0)
htmlentities (4.3.4) htmlentities (4.3.4)
httparty (0.16.2) httparty (0.16.2)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
@ -255,6 +264,10 @@ GEM
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
searchkick (3.1.3)
activemodel (>= 4.2)
elasticsearch (>= 5)
hashie
selenium-webdriver (3.14.0) selenium-webdriver (3.14.0)
childprocess (~> 0.5) childprocess (~> 0.5)
rubyzip (~> 1.2) rubyzip (~> 1.2)
@ -344,6 +357,7 @@ DEPENDENCIES
ruby-ole ruby-ole
rubyzip rubyzip
sass-rails (~> 5.0) sass-rails (~> 5.0)
searchkick
selenium-webdriver selenium-webdriver
sidekiq sidekiq
simple_xlsx_reader simple_xlsx_reader

@ -45,6 +45,8 @@ class AccountsController < ApplicationController
@user.activate @user.activate
# 必须要用save操作密码的保存是在users中 # 必须要用save操作密码的保存是在users中
if @user.save! if @user.save!
# todo user_extension
UserExtension.create!(user_id: @user.id)
# 注册完成手机号或邮箱想可以奖励500金币 # 注册完成手机号或邮箱想可以奖励500金币
RewardGradeService.call( RewardGradeService.call(
@user, @user,

@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base
# 考虑到安全参数问题多一次查询去掉Union # 考虑到安全参数问题多一次查询去掉Union
user = User.where(phone: login).first || User.where(mail: login).first user = User.where(phone: login).first || User.where(mail: login).first
if type.to_i == 1 && !user.nil? if type.to_i == 1 && !user.nil?
tip_exception("该手机号码或邮箱已被注册") tip_exception(-2, "该手机号码或邮箱已被注册")
elsif type.to_i == 2 && user.nil? elsif type.to_i == 2 && user.nil?
tip_exception("该手机号码或邮箱未注册") tip_exception("该手机号码或邮箱未注册")
end end

@ -203,13 +203,13 @@ class ExercisesController < ApplicationController
else else
@is_teacher_or = 1 @is_teacher_or = 1
@user_exercise_answer = 3 #教师页面 @user_exercise_answer = 3 #教师页面
@user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数 @user_commit_counts = @exercise.exercise_users.where(commit_status:1).size #已提交的用户数
end end
@ex_status = @exercise.get_exercise_status(current_user) @ex_status = @exercise.get_exercise_status(current_user)
exercise_id_array = [@exercise.id] exercise_id_array = [@exercise.id]
@exercise_publish_count = get_user_permission_course(exercise_id_array,2).count #是否存在已发布的 @exercise_publish_count = get_user_permission_course(exercise_id_array,2).size #是否存在已发布的
@exercise_unpublish_count = get_user_permission_course(exercise_id_array,1).count #是否存在未发布的 @exercise_unpublish_count = get_user_permission_course(exercise_id_array,1).size #是否存在未发布的
if (@exercise_publish_count == 0) && (@exercise_unpublish_count == 0) #即表示没有分班 if (@exercise_publish_count == 0) && (@exercise_unpublish_count == 0) #即表示没有分班
if @ex_status == 1 if @ex_status == 1
@ -1204,7 +1204,7 @@ class ExercisesController < ApplicationController
#筛选/分类,排序 #筛选/分类,排序
order = params[:order] order = params[:order]
if @exercise_users_list.exists? && @exercise_users_list.size > 0 if @exercise_users_list.present? && @exercise_users_list.size > 0
@exercise_users_count = @exercise_users_list.size #当前显示的全部成员数量 @exercise_users_count = @exercise_users_list.size #当前显示的全部成员数量
teacher_reviews = @exercise_users_list.exercise_review teacher_reviews = @exercise_users_list.exercise_review
teacher_unreviews = @exercise_users_list.exercise_unreview teacher_unreviews = @exercise_users_list.exercise_unreview

@ -477,7 +477,7 @@ class GamesController < ApplicationController
# 获取版本库文件内容 # 获取版本库文件内容
# 注如果本身path传错内容肯定也为空fork成功后可能短时间内也获取不到版本库内容 # 注如果本身path传错内容肯定也为空fork成功后可能短时间内也获取不到版本库内容
# params[:status] 1: 目录树点击的请求 0正常自动加载 # params[:status] 1: 目录树点击的请求 0正常自动加载
# 返回参数status -3 需要重试带retry参数-1 给出提示 # 返回参数status -1 系统统一报错提示;-3 需要轮训重试带retry参数-4 立即重试
def rep_content def rep_content
challenge_path = @game.challenge.try(:path) challenge_path = @game.challenge.try(:path)
if challenge_path.blank? if challenge_path.blank?
@ -490,22 +490,10 @@ class GamesController < ApplicationController
uid_logger("--rep_content: path is #{path}") uid_logger("--rep_content: path is #{path}")
begin begin
@content = git_fle_content(@myshixun.repo_path, path) || "" @content = git_fle_content(@myshixun.repo_path, path) || ""
rescue rescue Exception => e
# 思路: 异常首先应该考虑去恢复
if params[:retry].to_i == 1 if params[:retry].to_i == 1
begin begin
begin
# 检测TPM对应的路径代码是否正常
git_fle_content(@myshixun.shixun.repo_path, path)
rescue Exception => e
uid_logger_error("#{e.message}")
# 如果已发布的TPM实训也不能获取到内容那么肯定是版本库异常了
if @myshixun.shixun.try(:status) < 2
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
else
tip_exception("代码获取异常,请联系系统管理员")
end
end
# 如果模板没有问题,则通过中间层检测实训仓库是否异常 # 如果模板没有问题,则通过中间层检测实训仓库是否异常
# 监测版本库HEAD是否存在不存在则取最新的HEAD # 监测版本库HEAD是否存在不存在则取最新的HEAD
gitUrl = repo_url @myshixun.repo_path gitUrl = repo_url @myshixun.repo_path
@ -528,11 +516,17 @@ class GamesController < ApplicationController
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
# 报错继续retry
tip_exception(-3, "#{e.message}") if @myshixun.shixun.try(:status) < 2
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
else
# 报错继续retry
tip_exception(-3, "#{e.message}")
end
end end
end end
tip_exception(-3, "#{e.message}") # 有异常了,立即重试
tip_exception(-4, e.message)
end end
end end

@ -822,66 +822,98 @@ class HomeworkCommonsController < ApplicationController
@main_catrgory = @course.course_modules.where(module_type: "shixun_homework") @main_catrgory = @course.course_modules.where(module_type: "shixun_homework")
@homework_category = @main_catrgory.take.course_second_categories @homework_category = @main_catrgory.take.course_second_categories
## 我的实训 search = params[:search]
@shixuns = type = params[:type]
if params[:order_by] == 'mine' # 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
current_user.my_shixuns.unhidden if current_user.admin?
else @shixuns = Shixun.unhidden
if current_user.admin? else
Shixun.unhidden none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
@shixuns = Shixun.where.not(id: none_shixun_ids).unhidden
end
end
## 方向 @shixuns = Shixun.where.not(id: none_shixun_ids).unhidden
if params[:tag_level].present? && params[:tag_id].present?
@shixuns = @shixuns.filter_tag(params[:tag_level].to_i, params[:tag_id].to_i)
case params[:tag_level].to_i
when 1 #大类
@search_tags = Repertoire.find(params[:tag_id].to_i).name
when 2 #子类
@search_tags = SubRepertoire.find(params[:tag_id].to_i).name
when 3 #tag
tag = TagRepertoire.find(params[:tag_id].to_i)
@search_tags = "#{tag.sub_repertoire.name} / #{tag.name}"
end
end end
## 搜索关键字创建者、实训名称、院校名称 # 实训的所有标签
if params[:keyword].present? @tags = TagRepertoire.select([:id, :name]).joins(:shixuns).where(shixuns: {id: @shixuns}).distinct
keyword = params[:keyword].strip
@shixuns = @shixuns.joins(user: [user_extenison: :school]).
where("schools.name like '%#{keyword}%'
or concat(lastname, firstname) like '%#{keyword}%'
or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct
end
## 筛选 难度 if params[:search] && params[:search].strip != ""
if params[:diff].present? && params[:diff].to_i != 0 @shixuns = @shixuns.joins(:user).where("shixuns.name like ? or concat(users.lastname, users.firstname) like ?",
@shixuns = @shixuns.where(trainee: params[:diff]) "%#{search}%", "%#{search}%").distinct
end end
## 排序参数 unless type.blank? || type == "all"
bsort = params[:sort] || 'desc' @shixuns = @shixuns.joins(:shixun_tag_repertoires).where(shixun_tag_repertoires: {tag_repertoire_id: type}).distinct
case params[:order_by] || 'hot'
when 'hot'
@shixuns = @shixuns.order("myshixuns_count #{bsort}")
when 'mine'
@shixuns = @shixuns.order("shixuns.created_at #{bsort}")
else
@shixuns = @shixuns.order("myshixuns_count #{bsort}")
end end
@total_count = @shixuns.count @shixuns = @shixuns.select([:id, :name, :status, :myshixuns_count, :identifier, :user_id, :trainee]).reorder("shixuns.created_at desc")
@shixuns_count = @shixuns.size
## 分页参数 ## 分页参数
page = params[:page] || 1 page = params[:page] || 1
limit = params[:limit] || 15 @shixuns = @shixuns.includes(:challenges, user: [user_extension: :school]).page(page).per(10)
@shixuns = @shixuns.includes(:challenges, user: [user_extension: :school]).page(page).per(limit) # 新版用下面的代码
# ## 我的实训
# @shixuns =
# if params[:order_by] == 'mine'
# current_user.my_shixuns.unhidden
# else
# if current_user.admin?
# Shixun.unhidden
# else
# none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
#
# @shixuns = Shixun.where.not(id: none_shixun_ids).unhidden
# end
# end
#
# ## 方向
# if params[:tag_level].present? && params[:tag_id].present?
# @shixuns = @shixuns.filter_tag(params[:tag_level].to_i, params[:tag_id].to_i)
# case params[:tag_level].to_i
# when 1 #大类
# @search_tags = Repertoire.find(params[:tag_id].to_i).name
# when 2 #子类
# @search_tags = SubRepertoire.find(params[:tag_id].to_i).name
# when 3 #tag
# tag = TagRepertoire.find(params[:tag_id].to_i)
# @search_tags = "#{tag.sub_repertoire.name} / #{tag.name}"
# end
# end
#
# ## 搜索关键字创建者、实训名称、院校名称
# if params[:keyword].present?
# keyword = params[:keyword].strip
# @shixuns = @shixuns.joins(user: [user_extenison: :school]).
# where("schools.name like '%#{keyword}%'
# or concat(lastname, firstname) like '%#{keyword}%'
# or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct
# end
#
# ## 筛选 难度
# if params[:diff].present? && params[:diff].to_i != 0
# @shixuns = @shixuns.where(trainee: params[:diff])
# end
#
# ## 排序参数
# bsort = params[:sort] || 'desc'
# case params[:order_by] || 'hot'
# when 'hot'
# @shixuns = @shixuns.order("myshixuns_count #{bsort}")
# when 'mine'
# @shixuns = @shixuns.order("shixuns.created_at #{bsort}")
# else
# @shixuns = @shixuns.order("myshixuns_count #{bsort}")
# end
#
# @total_count = @shixuns.count
#
# ## 分页参数
# page = params[:page] || 1
# limit = params[:limit] || 15
#
# @shixuns = @shixuns.includes(:challenges, user: [user_extension: :school]).page(page).per(limit)
#
end end
def create_shixun_homework def create_shixun_homework

@ -662,8 +662,8 @@ class ShixunsController < ApplicationController
school_name = "%#{params[:school_name].to_s.strip}%" school_name = "%#{params[:school_name].to_s.strip}%"
if user_name.present? || school_name.present? if user_name.present? || school_name.present?
@users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND
LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE (LOWER(users.lastname) LIKE ? or users.phone like ?) AND LOWER(schools.name) LIKE
'#{school_name}'") ?", user_name, user_name, school_name)
else else
@users = User.none @users = User.none
end end

@ -89,7 +89,7 @@ module ExercisesHelper
percent = 0.0 percent = 0.0
questions.each do |ex| questions.each do |ex|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分 ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
ex_answers = ex.exercise_answers ex_answers = ex.exercise_answers.includes(:exercise_choice)
if ex.question_type != Exercise::PRACTICAL if ex.question_type != Exercise::PRACTICAL
ques_title = ex.question_title ques_title = ex.question_title
ques_less_title = nil ques_less_title = nil
@ -113,23 +113,27 @@ module ExercisesHelper
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置 standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
right_users_count = 0 #该问题的回答正确的人数 right_users_count = 0 #该问题的回答正确的人数
if ex.question_type == Exercise::MULTIPLE #多选题
#计算每个问题的答案人数 user_ids.each do |user_id|
user_ids.each do |user_id| answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
user_an_choice = ex_answers.where(user_id:user_id) if answer_choice_array.sort == standard_answer
answer_choice_array = [] right_users_count += 1
user_an_choice.each do |a| end
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
end end
if answer_choice_array == standard_answer else #单选题和判断题
right_users_count += 1 user_ids.each do |user_id|
answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).find_by(user_id:user_id)&.exercise_choice&.choice_position
if [answer_choice_array] == standard_answer
right_users_count += 1
end
end end
end end
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0 percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
ex.exercise_choices.each do |c| ex.exercise_choices.each do |c|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置 right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id) answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)
answer_users_count = answer_this_choice.count answer_users_count = answer_this_choice.size
if effictive_users_count == 0 if effictive_users_count == 0
answer_percent = 0.0 answer_percent = 0.0
else else
@ -170,7 +174,6 @@ module ExercisesHelper
else else
answer_percent = (user_count / effictive_users_count.to_f ).round(3) answer_percent = (user_count / effictive_users_count.to_f ).round(3)
end end
answer_option = { answer_option = {
:choice_position => index+1, :choice_position => index+1,
:choice_text => s_choice_text, :choice_text => s_choice_text,
@ -200,9 +203,9 @@ module ExercisesHelper
question_answer_infos.push(wrong_answer_position) question_answer_infos.push(wrong_answer_position)
elsif ex.question_type == Exercise::SUBJECTIVE #主观题 elsif ex.question_type == Exercise::SUBJECTIVE #主观题
ex_score = ex&.question_score ex_score = ex&.question_score
full_scores = effictive_users.search_exercise_answer("score",ex_score).count #满分人数 full_scores = effictive_users.search_exercise_answer("score",ex_score).size #满分人数
no_full_scores = effictive_users.exercise_no_full_scores(ex_score).count #部分分数人数 no_full_scores = effictive_users.exercise_no_full_scores(ex_score).size #部分分数人数
zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的及未评阅的 zero_scores = effictive_users.search_exercise_answer("score",0.0).size #包含为0分的及未评阅的
un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数 un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数
if un_review_scores < 0 if un_review_scores < 0
un_review_scores = 0 un_review_scores = 0
@ -415,7 +418,7 @@ module ExercisesHelper
user_answer_content = answer_choice_array.sort user_answer_content = answer_choice_array.sort
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.count > 0 if standard_answer.size > 0
q_score_1 = q.question_score q_score_1 = q.question_score
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时每个answer的分数均摊。 # q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时每个answer的分数均摊。
else else

@ -1,6 +1,5 @@
class ChallengeTag < ApplicationRecord class ChallengeTag < ApplicationRecord
# TODO: ES feature include Searchable::Dependents::ChallengeTag
# include Searchable::Dependents::ChallengeTag
belongs_to :challenge, counter_cache: true belongs_to :challenge, counter_cache: true
belongs_to :challenge_choose, optional: true belongs_to :challenge_choose, optional: true

@ -1,6 +1,5 @@
class Course < ApplicationRecord class Course < ApplicationRecord
# TODO: ES feature include Searchable::Course
# include Searchable::Course
has_many :boards, dependent: :destroy has_many :boards, dependent: :destroy

@ -178,13 +178,12 @@ class Exercise < ApplicationRecord
ex_answer_user = exercise_users.where(user_id: user.id).select(:start_at,:end_at,:commit_status) ex_answer_user = exercise_users.where(user_id: user.id).select(:start_at,:end_at,:commit_status)
user_ex_status = get_exercise_status(user) user_ex_status = get_exercise_status(user)
user_status = 2 user_status = 2
if ex_answer_user.exists? && (ex_answer_user.first&.start_at.present? || ex_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 if ex_answer_user.present? && (ex_answer_user.first&.start_at.present? || ex_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.first.commit_status user_status = ex_answer_user.first.commit_status
end end
if ex_answer_user.exists? && ex_answer_user.first&.start_at.blank? && user_ex_status == 3 if ex_answer_user.present? && ex_answer_user.first&.start_at.blank? && user_ex_status == 3
user_status = 4 user_status = 4
end end
user_status user_status
end end

@ -1,6 +1,5 @@
class Memo < ApplicationRecord class Memo < ApplicationRecord
# TODO: ES feature include Searchable::Memo
# include Searchable::Memo
has_many :memo_tag_repertoires, :dependent => :destroy has_many :memo_tag_repertoires, :dependent => :destroy
has_many :tag_repertoires, :through => :memo_tag_repertoires has_many :tag_repertoires, :through => :memo_tag_repertoires

@ -26,6 +26,7 @@ module Searchable::Memo
{ {
descendants_contents: Util.map_or_pluck(descendants, :content) descendants_contents: Util.map_or_pluck(descendants, :content)
.map { |content| Util.extract_content(content)[0..Searchable::MAXIMUM_LENGTH] } .map { |content| Util.extract_content(content)[0..Searchable::MAXIMUM_LENGTH] }
.join('<br/>')
} }
end end

@ -31,7 +31,7 @@ module Searchable::Shixun
.each_with_index.map { |subject, index| "#{index + 1}#{subject}" } .each_with_index.map { |subject, index| "#{index + 1}#{subject}" }
{ {
challenge_names: challenge_names, challenge_names: challenge_names.join(' '),
challenge_tag_names: Util.map_or_pluck(challenge_tags, :name).uniq.join(' ') challenge_tag_names: Util.map_or_pluck(challenge_tags, :name).uniq.join(' ')
} }
end end

@ -31,15 +31,9 @@ module Searchable::Subject
end end
def searchable_stages_data def searchable_stages_data
subject_stages = subject_stages = stages.map { |stage| "#{stage.name} #{Util.extract_content(stage.description)}"[0..Searchable::MAXIMUM_LENGTH] }
stages.map do |stage|
{ { subject_stages: subject_stages.join('<br/>') }
name: stage.name,
description: Util.extract_content(stage.description)[0..Searchable::MAXIMUM_LENGTH]
}
end
{ subject_stages: subject_stages}
end end
def to_searchable_json def to_searchable_json

@ -1,6 +1,5 @@
class Shixun < ApplicationRecord class Shixun < ApplicationRecord
# TODO: ES feature include Searchable::Shixun
# include Searchable::Shixun
# status: 0编辑 1申请发布 2正式发布 3关闭 -1软删除 # status: 0编辑 1申请发布 2正式发布 3关闭 -1软删除
# hide_code 隐藏代码窗口 # hide_code 隐藏代码窗口

@ -1,6 +1,5 @@
class Stage < ApplicationRecord class Stage < ApplicationRecord
# TODO: ES feature include Searchable::Dependents::Stage
# include Searchable::Dependents::Stage
belongs_to :subject, counter_cache: true belongs_to :subject, counter_cache: true

@ -2,8 +2,7 @@
# 可以在初始创建的时候 # 可以在初始创建的时候
class Subject < ApplicationRecord class Subject < ApplicationRecord
# TODO: ES feature include Searchable::Subject
# include Searchable::Subject
#status :0 编辑中 1 审核中 2 发布 #status :0 编辑中 1 审核中 2 发布
belongs_to :repertoire belongs_to :repertoire

@ -1,7 +1,6 @@
class User < ApplicationRecord class User < ApplicationRecord
include Watchable include Watchable
# TODO: ES feature include Searchable::Dependents::User
# include Searchable::Dependents::User
# Account statuses # Account statuses
STATUS_ANONYMOUS = 0 STATUS_ANONYMOUS = 0

@ -3,7 +3,7 @@ class UserExtension < ApplicationRecord
enum identity: { teacher: 0, student: 1, professional: 2, developer: 3 } enum identity: { teacher: 0, student: 1, professional: 2, developer: 3 }
belongs_to :user, touch: true belongs_to :user, touch: true
belongs_to :school belongs_to :school, optional: true
belongs_to :department, optional: true belongs_to :department, optional: true
def identity_text def identity_text

@ -1,12 +1,27 @@
# json.shixun_list @shixuns do |shixun|
# json.shixun_identifier shixun.identifier
# json.name shixun.name
# json.creator shixun.user&.full_name
# json.creator_login shixun.user&.login
# json.school shixun.user&.school_name
# json.myshixuns_count shixun.myshixuns_count
# json.level level_to_s(shixun.trainee)
# json.challenge_tags shixun.challenge_tags_name
# end
json.shixun_list @shixuns do |shixun| json.shixun_list @shixuns do |shixun|
json.shixun_identifier shixun.identifier json.shixun_id shixun.id
json.name shixun.name json.identifier shixun.identifier
json.creator shixun.user&.full_name json.shixun_name shixun.name
json.creator_login shixun.user&.login
json.school shixun.user&.school_name
json.myshixuns_count shixun.myshixuns_count json.myshixuns_count shixun.myshixuns_count
json.school shixun.user&.school_name
json.creator shixun.user&.full_name
json.level level_to_s(shixun.trainee) json.level level_to_s(shixun.trainee)
json.challenge_tags shixun.challenge_tags_name end
json.tags @tags do |tag|
json.tag_id tag.id
json.tag_name tag.name
end end
json.shixuns_count @total_count json.shixuns_count @total_count

@ -0,0 +1,13 @@
defaults: &defaults
url: http://localhost:9200
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
url: 'http://elastic:Elas+ucloud123@106.75.27.125:59200/'
# url: 'http://elastic:TEST_elastickibana321@es-cn-0pp174wsj000iubdx.public.elasticsearch.aliyuncs.com'

@ -0,0 +1,2 @@
redis_config = Rails.application.config_for(:elasticsearch)
ENV['ELASTICSEARCH_URL'] = redis_config['url']
Loading…
Cancel
Save