From c1a485f33a16d2e061fc55dd362db115cb2152b7 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 20 Jul 2019 10:36:24 +0800 Subject: [PATCH 1/4] fix es highlight --- app/services/concerns/elasticsearch_able.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/services/concerns/elasticsearch_able.rb b/app/services/concerns/elasticsearch_able.rb index c08aab029..c1640470c 100644 --- a/app/services/concerns/elasticsearch_able.rb +++ b/app/services/concerns/elasticsearch_able.rb @@ -20,7 +20,15 @@ module ElasticsearchAble def highlight_options { fragment_size: EduSetting.get('es_highlight_fragment_size') || 30, - tag: '' + tag: '', + fields: { + challenge_names: { type: 'plain' }, + challenge_tag_names: { type: 'plain' }, + description: { type: 'plain' }, + subject_stages: { type: 'plain' }, + content: { type: 'plain' }, + descendants_contents: { type: 'plain' }, + } } end From 27465a3549217defbf8273f617f868f39bb1e085 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 20 Jul 2019 10:36:39 +0800 Subject: [PATCH 2/4] fix es highlight --- app/services/concerns/elasticsearch_able.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/concerns/elasticsearch_able.rb b/app/services/concerns/elasticsearch_able.rb index c1640470c..59c2c890b 100644 --- a/app/services/concerns/elasticsearch_able.rb +++ b/app/services/concerns/elasticsearch_able.rb @@ -22,6 +22,8 @@ module ElasticsearchAble fragment_size: EduSetting.get('es_highlight_fragment_size') || 30, tag: '', fields: { + name: { type: 'plain' }, + subject: { type: 'plain' }, challenge_names: { type: 'plain' }, challenge_tag_names: { type: 'plain' }, description: { type: 'plain' }, From 0c91a327ccfc006f197781704d39142a24d37777 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 20 Jul 2019 10:53:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190720025309_add_ts_mem_for_outputs.rb | 5 +++++ db/migrate/20190720025341_add_ts_time_for_outputs.rb | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20190720025309_add_ts_mem_for_outputs.rb create mode 100644 db/migrate/20190720025341_add_ts_time_for_outputs.rb diff --git a/db/migrate/20190720025309_add_ts_mem_for_outputs.rb b/db/migrate/20190720025309_add_ts_mem_for_outputs.rb new file mode 100644 index 000000000..1cf3f3e6f --- /dev/null +++ b/db/migrate/20190720025309_add_ts_mem_for_outputs.rb @@ -0,0 +1,5 @@ +class AddTsMemForOutputs < ActiveRecord::Migration[5.2] + def change + add_column :outputs, :ts_mem, :float + end +end diff --git a/db/migrate/20190720025341_add_ts_time_for_outputs.rb b/db/migrate/20190720025341_add_ts_time_for_outputs.rb new file mode 100644 index 000000000..a5366fbd0 --- /dev/null +++ b/db/migrate/20190720025341_add_ts_time_for_outputs.rb @@ -0,0 +1,5 @@ +class AddTsTimeForOutputs < ActiveRecord::Migration[5.2] + def change + add_column :outputs, :ts_time, :float + end +end From 4d3dbcee4a6ce8605ea065f3f27165923f894b83 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 20 Jul 2019 13:14:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/controllers/shixuns_controller.rb | 1 + app/controllers/subjects_controller.rb | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a78aa028b..b937d293d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -60,6 +60,7 @@ class CoursesController < ApplicationController # FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a") # .order("courses.id = 1309 desc, a desc") if @order == "mine" + tip_exception(401, "..") unless current_user.logged? @courses = Course.joins(:course_members) .where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id) elsif @order == "created_at" diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f1e36a5c8..35488ecc5 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -22,6 +22,7 @@ class ShixunsController < ApplicationController ## 我的实训 @shixuns = if params[:order_by] == 'mine' + tip_exception(401, "..") unless current_user.logged? current_user.my_shixuns else Shixun.unhidden diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 7857f2ec6..4d256f3dc 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -37,6 +37,8 @@ class SubjectsController < ApplicationController else # 我的路径 if reorder == "mine" + tip_exception(401, "..") unless current_user.logged? + mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in (select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id) manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id) @@ -137,7 +139,7 @@ class SubjectsController < ApplicationController if current_user.admin? @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where(hidden: 0) else - none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) + none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where.not(id: none_shixun_ids).where(hidden: 0) end @@ -174,7 +176,7 @@ class SubjectsController < ApplicationController WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) @courses = Course.where(id: course_ids) - @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) + @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id) end def send_to_course