diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 37cfed3fb..665eaa294 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -29,7 +29,7 @@ class HomeController < ApplicationController @subjects = Subject.where(homepage_show: 1).includes(:shixuns, :repertoire).limit(8) @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc") - @stu_users = User.includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") + @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") end def search diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index 4309eec26..e05a813f4 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -14,7 +14,7 @@ namespace :excellent_course_exercise do course = Course.find_by(id: course_id) course.exercises.each_with_index do |exercise, index| - if exercise.exercise_users.where(commit_status: 1).count == 0 + # if exercise.exercise_users.where(commit_status: 1).count == 0 # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 if index == 0 members = course.students.order("id asc").limit(participant_count) @@ -26,7 +26,7 @@ namespace :excellent_course_exercise do members = course.students.order("id asc").limit(new_participant_count) update_exercise_user(exercise, members, new_pass_count) end - end + # end end end diff --git a/lib/tasks/public_message.rake b/lib/tasks/public_message.rake index 00299cabc..e51917a2e 100644 --- a/lib/tasks/public_message.rake +++ b/lib/tasks/public_message.rake @@ -1,4 +1,4 @@ -# bundle exec rake sync:public_message args=149,2903 +# RAILS_ENV=production bundle exec rake sync:sigle_message args=3,-1,8848,48337,'2017-07-23','2017-10-31',1000 namespace :sync do if ENV['args'] subject_id = ENV['args'].split(",")[0] # 对应课程的id @@ -33,7 +33,7 @@ namespace :sync do else shixun_ids = Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where subject_id=#{subject_id}) ").map(&:shixun_id) - discusses = Discuss.where("parent_id is null").where(dis_id: shixun_ids) + discusses = Discuss.where("parent_id is null and created_at between '#{start_time}' and '#{end_time}'").where(dis_id: shixun_ids) end discusses.each do |discuss| diff --git a/lib/tasks/user_login.rake b/lib/tasks/user_login.rake new file mode 100644 index 000000000..31dfbb2b4 --- /dev/null +++ b/lib/tasks/user_login.rake @@ -0,0 +1,28 @@ +namespace :user do + task :update_login => :environment do + begin + user_count = ENV['args'].split(",")[0].to_i # 更新的用户数 + status = ENV['args'].split(",")[1] # 测试用户类型 + base_login = ENV['args'].split(",")[2] # 基本的用户参数 + + users = User.where(:is_test => status).limit(user_count) + users.each_with_index do |user, i| + puts i + + no = sprintf("%04d", i) + login = "#{base_login}#{no}" + puts no + puts login + + sql1 = "update users set login='#{login}' where id=#{user.id}" + sql2 = "update users set lastname='#{login}' where id=#{user.id}" + sql3 = "update users set nickname='#{login}' where id=#{user.id}" + ActiveRecord::Base.connection.execute(sql1) + ActiveRecord::Base.connection.execute(sql2) + ActiveRecord::Base.connection.execute(sql3) + end + rescue Exception => e + Rails.logger.error(e.message) + end + end +end \ No newline at end of file