Merge branch 'develop' into dev_aliyun

topic_bank
jingquan huang 5 years ago
commit 4f3a4ea34f

@ -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

@ -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

@ -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|

@ -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
Loading…
Cancel
Save