dev_bj
caishi 5 years ago
commit cbb01a166b

@ -17,22 +17,27 @@ class CompetitionTeamsController < ApplicationController
@team_user_ids = @team.team_members.pluck(:user_id) @team_user_ids = @team.team_members.pluck(:user_id)
shixuns = Shixun.where(user_id: @team_user_ids, status: 2) shixuns = Shixun.where(user_id: @team_user_ids, status: 2).where('shixuns.created_at > ?', Time.parse('2018-06-01'))
shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2')
shixuns = shixuns.joins('left join myshixuns on myshixuns.shixun_id = shixuns.id and exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count') shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count')
@shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator) @shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator)
@myshixun_count_map = Myshixun.where(shixun_id: @shixuns.map(&:id))
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') shixun_ids = @shixuns.map(&:id)
.group('shixun_id').count @myshixun_count_map = get_valid_myshixun_count(shixun_ids)
# forked shixun valid myshixun count
forked_shixun_map = Shixun.where(status: 2, fork_from: shixun_ids).select('id, fork_from')
forked_shixun_map = forked_shixun_map.each_with_object({}) { |sx, obj| obj[sx.id] = sx.fork_from }
forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys)
forked_myshixun_count_map.each { |k, v| @myshixun_count_map[forked_shixun_map[k]] += v }
# todo使用新版course_members # todo使用新版course_members
course_ids = Course.joins('join members on members.course_id = courses.id') course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01'))
.joins('join members on members.course_id = courses.id')
.joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)') .joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)')
.where(members: { user_id: @team_user_ids }).pluck(:id) .where(members: { user_id: @team_user_ids }).pluck(:id)
courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()') courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()')
@courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count') @courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count')
.group('courses.id').order('shixun_homework_count desc') .group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0')
@course_myshixun_map = Myshixun.joins(student_works: :homework_common) @course_myshixun_map = Myshixun.joins(student_works: :homework_common)
.where(homework_commons: { course_id: @courses.map(&:id) }) .where(homework_commons: { course_id: @courses.map(&:id) })
@ -322,4 +327,10 @@ class CompetitionTeamsController < ApplicationController
true true
end end
def get_valid_myshixun_count(ids)
Myshixun.where(shixun_id: ids)
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('shixun_id').count
end
end end

@ -360,7 +360,7 @@ class UsersService
g = Gitlab.client g = Gitlab.client
g.edit_user(@current_user.gid, :password => params[:new_password]) g.edit_user(@current_user.gid, :password => params[:new_password])
rescue Exception => e rescue Exception => e
logger.error "change users password failed! ===> #{e}" Rails.logger.error "change users password failed! ===> #{e}"
end end
end end
end end

@ -11,8 +11,8 @@
<th width="10%">创建者</th> <th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th> <th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学习人数</th> <th width="10%">学习人数</th>
<th width="15%">fork版的学习人数</th> <th width="15%" data-tip-down="fork该实训产生的新实训学习总人数">fork版的学习人数</th>
<th width="10%">有效作品数</th> <th width="10%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th> <th width="15%">经验值</th>
</tr> </tr>
</thead> </thead>
@ -38,7 +38,7 @@
</td> </td>
<td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td> <td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td>
<td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td> <td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td>
<th width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></th> <td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%">--</td> <td width="15%">--</td>
</tr> </tr>
<% end %> <% end %>
@ -65,7 +65,7 @@
<th width="40%" class="edu-txt-left">名称</th> <th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学生数量</th> <th width="10%">学生数量</th>
<th width="15%">发布的实训作业数量</th> <th width="15%">发布的实训作业数量</th>
<th width="10%">有效作品数</th> <th width="10%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th> <th width="15%">经验值</th>
</tr> </tr>
</thead> </thead>
@ -88,7 +88,7 @@
</td> </td>
<td width="10%"><%= course.members_count %></td> <td width="10%"><%= course.members_count %></td>
<td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td> <td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td>
<th width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></th> <td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%">--</td> <td width="15%">--</td>
</tr> </tr>
<% end %> <% end %>

@ -15,11 +15,11 @@
<p class="font-22 enter_title padding30 clearfix"> <p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30"> <span class="fl ml30">
<span class="mr20 font-bd"><%= first_section.try(:name) %></span> <span class="mr20 font-bd"><%= first_section.try(:name) %></span>
<span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %> ~ <%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span> <span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %>~<%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span>
</span> </span>
<span class="fr mr30"> <span class="fr mr30">
<span class="mr20 font-bd"><%= second_section.try(:name) %></span> <span class="mr20 font-bd"><%= second_section.try(:name) %></span>
<span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %> ~ <%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span> <span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %>~<%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span>
</span> </span>
</p> </p>
<li class="inline enter_btn mt20"> <li class="inline enter_btn mt20">

@ -5,7 +5,15 @@
<% @teams.each do |team| %> <% @teams.each do |team| %>
<li class="clearfix"> <li class="clearfix">
<%= link_to image_tag(url_to_avatar(team.user), :width => "40", :height => "40", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(team.user), :width => "40", :height => "40", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %>
<% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to competition_team_path(id: team.id) do %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% end %>
<% else %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span> <span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% end %>
<% if @maximum_staff > 1 %> <% if @maximum_staff > 1 %>
<span class="fl mr40 mt10" style="width: 270px;"> <span class="fl mr40 mt10" style="width: 270px;">
<% team.teachers.each do |teacher| %> <% team.teachers.each do |teacher| %>

@ -97,7 +97,7 @@
<a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认退出战队')">退出</a> <a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认退出战队')">退出</a>
<% end %> <% end %>
<% end %> <% end %>
<a href="javascript:void(0)" class="enrollOperation">进入大赛</a> <%= link_to '进入大赛', competition_path(@competition), class: 'enrollOperation' %>
<% if @competition.identifier == 'gcc-course-2019' %> <% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to '战队详情', competition_team_path(id: team.id), class: 'enrollOperation' %> <%= link_to '战队详情', competition_team_path(id: team.id), class: 'enrollOperation' %>
<% end %> <% end %>

@ -66,7 +66,7 @@
//你的lib目录的路径我这边用JSP做测试的 //你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/", path: "/editormd/lib/",
tex: true, tex: true,
watch:false, watch:true,
toolbarIcons: function () { toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini // Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right. // Using "||" set icons align right.

@ -864,7 +864,7 @@ table.tBodyScroll thead th{
height: 20px; height: 20px;
line-height: 19px!important; line-height: 19px!important;
margin-top: 18px; margin-top: 18px;
margin-left: 15px; margin-left: 10px;
} }
/*弹框*/ /*弹框*/
.c-l-box{background: rgba(139,163,183,0.08);height: 226px;overflow-y: auto;width: 100%;padding: 20px 20px 0px 20px;box-sizing: border-box;} .c-l-box{background: rgba(139,163,183,0.08);height: 226px;overflow-y: auto;width: 100%;padding: 20px 20px 0px 20px;box-sizing: border-box;}

Loading…
Cancel
Save