From 847266f9cc0be6337d0243b509c49bca04b5f512 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 26 Dec 2019 16:33:25 +0800 Subject: [PATCH 1/4] 1 --- app/models/hack_set.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 9ef0412ed..9e2186fb5 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord - #validates :input, presence: { message: "测试集输入不能为空" } - #validates :output, presence: { message: "测试集输出不能为空" } + validates :input, presence: { message: "测试集输入不能为空" } + validates :output, presence: { message: "测试集输出不能为空" } validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" # 编程题测试集 belongs_to :hack From 6cc67dbdf914b5ce45cac585e0eb56ad80ddcd14 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 26 Dec 2019 16:46:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hack_user_lastest_codes_controller.rb | 10 +++++++--- app/models/hack_user_lastest_code.rb | 2 ++ app/views/hack_user_lastest_codes/show.json.jbuilder | 1 + config/routes.rb | 1 + ...20191226083915_add_notes_hack_user_lastest_codes.rb | 5 +++++ 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 655fea471..ff0af5958 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -1,9 +1,9 @@ class HackUserLastestCodesController < ApplicationController before_action :require_login, except: [:listen_result] - before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, + before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code, :add_notes, :listen_result, :result, :submit_records, :restore_initial_code] before_action :update_user_hack_status, only: [:code_debug, :code_submit] - #before_action :require_auth_identity, only: [:restore_initial_code, :sync_code] + before_action :require_auth_identity, only: [:add_notes] before_action :require_manager_identity, only: [:show, :update_code, :restore_initial_code, :sync_code] def show @@ -67,7 +67,6 @@ class HackUserLastestCodesController < ApplicationController end - # 提交记录详情 def record_detail @hack_user = HackUserCode.find params[:id] @@ -109,6 +108,11 @@ class HackUserLastestCodesController < ApplicationController end + def add_notes + @my_hack.update_attribute(:notes, params[:notes]) + render_ok + end + private def find_my_hack @my_hack = HackUserLastestCode.find_by(identifier: params[:identifier]) diff --git a/app/models/hack_user_lastest_code.rb b/app/models/hack_user_lastest_code.rb index 830f16dde..99582af41 100644 --- a/app/models/hack_user_lastest_code.rb +++ b/app/models/hack_user_lastest_code.rb @@ -12,4 +12,6 @@ class HackUserLastestCode < ApplicationRecord scope :mine_hack, ->(author_id){ where(user_id: author_id) } scope :passed, -> {where(status: 1)} + validates_length_of :notes, maximum: 5000, message: "笔记不能超过5000个字" + end diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder index 098c24546..a158d074f 100644 --- a/app/views/hack_user_lastest_codes/show.json.jbuilder +++ b/app/views/hack_user_lastest_codes/show.json.jbuilder @@ -5,6 +5,7 @@ json.hack do json.code @my_hack.code json.pass_count @hack.pass_num json.submit_count @hack.submit_num + json.notes @my_hack.notes json.modify_code @modify json.comments_count @hack.discusses.count json.user_praise @hack.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0 diff --git a/config/routes.rb b/config/routes.rb index 7a68ed5e2..f9ed12dbe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,6 +90,7 @@ Rails.application.routes.draw do get :submit_records post :restore_initial_code post :sync_code + post :add_notes end collection do diff --git a/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb b/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb new file mode 100644 index 000000000..518e6d610 --- /dev/null +++ b/db/migrate/20191226083915_add_notes_hack_user_lastest_codes.rb @@ -0,0 +1,5 @@ +class AddNotesHackUserLastestCodes < ActiveRecord::Migration[5.2] + def change + add_column :hack_user_lastest_codes, :notes, :longtext + end +end From 6ea67b6771788cfea48ae5aafe5e9e7df7ec747c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 26 Dec 2019 17:25:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E9=80=89=E7=94=A8jupter=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixun_search_service.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 248d7d176..32488a7c3 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -33,6 +33,10 @@ class ShixunSearchService < ApplicationService @shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1]) end + if params[:no_jupyter] + @shixuns = @shixuns.where(is_jupyter: 0) + end + ## 筛选 难度 if params[:diff].present? && params[:diff].to_i != 0 @shixuns = @shixuns.where(trainee: params[:diff]) From ac3d87cf93e1500d47135049092621cebe485370 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 26 Dec 2019 17:26:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20191226092304_modify_task_pass_2_for_challenges.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb diff --git a/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb b/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb new file mode 100644 index 000000000..f03039aa2 --- /dev/null +++ b/db/migrate/20191226092304_modify_task_pass_2_for_challenges.rb @@ -0,0 +1,8 @@ +class ModifyTaskPass2ForChallenges < ActiveRecord::Migration[5.2] + def change + challenges = Challenge.where("task_pass like '%frac%'") + challenges.find_each do |c| + c.update_column(:task_pass, c.task_pass.gsub('\f\frac', '\frac')) + end + end +end