From 2de37f71d26688b58b1179947b5f54cfddf0d3d0 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 3 Aug 2019 09:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E9=94=99=E8=AF=AF=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 3 ++- .../20190801084533_add_praises_count_to_libraries.rb | 12 ++++++------ .../20190803014642_add_exec_time_to_evaluation.rb | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20190803014642_add_exec_time_to_evaluation.rb diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 1d6b15969..fe31c4fe2 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -265,9 +265,10 @@ class MyshixunsController < ApplicationController # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 # 自动保存的时候evaluate为0;点评测的时候为1 if params[:evaluate] == 1 + exec_time = @game.challenge.pluck(:exec_time) @sec_key = generate_identifier(EvaluateRecord, 12) record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id, - :identifier => @sec_key) + :identifier => @sec_key, :exec_time => exec_time) uid_logger("-- game build: file update #{@sec_key}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") end unless @hide_code diff --git a/db/migrate/20190801084533_add_praises_count_to_libraries.rb b/db/migrate/20190801084533_add_praises_count_to_libraries.rb index 6a619104d..b773cf918 100644 --- a/db/migrate/20190801084533_add_praises_count_to_libraries.rb +++ b/db/migrate/20190801084533_add_praises_count_to_libraries.rb @@ -1,10 +1,10 @@ class AddPraisesCountToLibraries < ActiveRecord::Migration[5.2] def change - add_column :libraries, :praises_count, :integer, :default => 0 - - Library.find_each do |library| - praises_count = library.praise_treads.count - library.update_column(:praises_count, praises_count) - end + # add_column :libraries, :praises_count, :integer, :default => 0 + # + # Library.find_each do |library| + # praises_count = library.praise_treads.count + # library.update_column(:praises_count, praises_count) + # end end end diff --git a/db/migrate/20190803014642_add_exec_time_to_evaluation.rb b/db/migrate/20190803014642_add_exec_time_to_evaluation.rb new file mode 100644 index 000000000..9f2af8b29 --- /dev/null +++ b/db/migrate/20190803014642_add_exec_time_to_evaluation.rb @@ -0,0 +1,5 @@ +class AddExecTimeToEvaluation < ActiveRecord::Migration[5.2] + def change + add_column :evaluate_records, :exec_time, :integer + end +end