Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_hs
杨树明 6 years ago
commit 0443f2a1b5

@ -438,7 +438,7 @@ module ApplicationHelper
content_tag(:span, text, opts)
end
def sort_tag(content, opts)
def sort_tag(content = '', **opts)
options = {}
options[:sort_by] = opts.delete(:name)
is_current_sort = params[:sort_by].to_s == options[:sort_by]
@ -450,10 +450,13 @@ module ApplicationHelper
when 'asc' then 'fa-sort-amount-asc'
else ''
end
opts[:style] = "#{opts[:style]} ;position: relative;"
content_tag(:span, opts) do
link_to path, remote: true do
content += content_tag(:i, '', class: "fa color-light-green ml-1 #{arrow_class}") if is_current_sort
content = content_tag(:span) { yield } if block_given?
content += content_tag(:i, '', class: "fa color-light-green ml-1 #{arrow_class}", style: 'position: absolute;top:0;') if is_current_sort
raw content
end
end

@ -1,19 +1,21 @@
<table class="table table-hover daily-school-statistic-list-table">
<thead class="thead-light">
<tr>
<th width="14%" class="text-left">单位名称</th>
<th width="12%" class="text-left">单位名称</th>
<th width="10%"><%= sort_tag('教师总数', name: 'teacher_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('学生总数', name: 'student_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: admins_daily_school_statistics_path) %></th>
<th width="14%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('实训总数', name: 'shixun_count', path: admins_daily_school_statistics_path) %></th>
<th width="12%">
<%= sort_tag('实训评测总数', name: 'shixun_evaluate_count', path: admins_daily_school_statistics_path) %>
<th width="13%">
<%= sort_tag(name: 'shixun_evaluate_count', path: admins_daily_school_statistics_path) do %>
实训评测总数
<i class="fa fa-question-circle" data-toggle="tooltip" data-html="true" data-placement="top" title="数据更新时间为<br/>当日6点、12点、18点、24点"></i>
<% end %>
</th>
<th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="11%"><%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="11%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: admins_daily_school_statistics_path) %></th>
<th width="13%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %></th>
</tr>
</thead>

@ -54,19 +54,60 @@ namespace :sync do
discusses = Discuss.where(dis_id: shixun_id).where("parent_id is null and created_at >? and created_at <?", start_time, end_time)
discusses.each do |discuss|
rand_created_on = random_time start_time, end_time
puts discuss.id
# 找到所有的子回复
replies = Discuss.where(parent_id: discuss.id)
# 如果有子回复,除了创建父回复外,还需要同步子回复
new_message = Message.create!(board_id: board_id.to_i, author_id: discuss.user_id, parent_id: message_id, root_id: message_id)
MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content))
new_message.update_columns(created_on: rand_created_on, updated_on: rand_created_on)
message_detail = MessageDetail.create!(message_id: new_message.id, content: discuss.try(:content))
message_detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
if replies.present?
replies.each do |reply|
puts("reply id si #{reply.id}")
reply_time = random_time(start_time, end_time)
while reply_time > rand_created_on
reply_time = random_time(start_time, end_time)
end
reply_message = Message.create!(board_id: board_id.to_i, author_id: reply.user_id, parent_id: new_message.id, root_id: message_id)
MessageDetail.create!(message_id: reply_message.id, content: reply.try(:content))
reply_message.update_columns(created_on: reply_time, updated_on: reply_time)
reply_message_detail = MessageDetail.create!(message_id: reply_message.id, content: reply.try(:content))
reply_message_detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
end
end
end
def min_swith(time)
puts time
return time < 9 ? "0#{time}" : time
end
def random_time(start_time, end_time)
hour = (6..23).to_a.sample(1).first
min = rand(60)
sec = rand(60)
start_time = Date.parse(start_time)
end_time = Date.parse(end_time)
date = (start_time..end_time).to_a.sample(1).first
time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}"
puts time
time
end
# 子评论的时间必须小于父评论
def smaller_time(parent_time, start_time, end_time)
large_time = random_time(start_time, end_time)
while large_time > parent_time
large_time = random_time(start_time, end_time)
end
large_time
end
end
end

Loading…
Cancel
Save