dev_bj
daiao 5 years ago
commit 4e5a5c4bce

@ -19,12 +19,16 @@ class CompetitionTeamsController < ApplicationController
shixuns = Shixun.where(user_id: @team_user_ids, status: 2).where('shixuns.created_at > ?', Time.parse('2018-06-01')) 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.where('courses.created_at > ?', Time.parse('2018-06-01')) course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01'))
@ -323,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

@ -14,7 +14,7 @@
<% size = judge_Chinese_num attachment.filename %> <% size = judge_Chinese_num attachment.filename %>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden color-grey fl', :size => size, :style => 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;font-family: Consolas;', :readonly => 'readonly') %> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden color-grey fl', :size => size, :style => 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;font-family: Consolas;', :readonly => 'readonly') %>
<span class="color-grey mr10 fl"><%= number_to_human_size attachment.filesize %></span> <span class="color-grey mr10 fl"><%= number_to_human_size attachment.filesize %></span>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> <%= link_to('<i class="iconfont icon-fujian mr5 color-green fl font-14"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt1') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<%= hidden_field_tag "attachments[p#{i}][attachment_id]", attachment.id %> <%= hidden_field_tag "attachments[p#{i}][attachment_id]", attachment.id %>
</span> </span>
@ -24,7 +24,7 @@
<label class="panel-form-label fl">&nbsp;</label> <label class="panel-form-label fl">&nbsp;</label>
<i class="iconfont icon-fujian mr5 color-green fl font-14" aria-hidden="true"></i> <i class="iconfont icon-fujian mr5 color-green fl font-14" aria-hidden="true"></i>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'hidden atta_input readonly color-grey fl', :style => 'border:none; max-width:980px;', :readonly => 'readonly') %> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'hidden atta_input readonly color-grey fl', :style => 'border:none; max-width:980px;', :readonly => 'readonly') %>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt2') unless attachment.id.nil? %> <%= link_to('<i class="iconfont icon-fujian mr5 color-green fl font-14"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt1') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>

@ -7,9 +7,11 @@
<% end%> <% end%>
<span title="<%= attachment.filename%>" id = "attachment_"> <span title="<%= attachment.filename%>" id = "attachment_">
<% if options[:length] %> <% if options[:length] %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%> <i class="iconfont icon-fujian color-green font-14 mr10 fl lineh-20 mt3"></i>
<%= link_to_short_attachment attachment,:download => true,:length => options[:length] -%>
<% else %> <% else %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true, :length => 32 -%> <i class="iconfont icon-fujian color-green font-14 mr10 fl lineh-20 mt3"></i>
<%= link_to_short_attachment attachment,:download => true, :length => 32 -%>
<% end %> <% end %>
</span> </span>
<%if is_float%> <%if is_float%>

@ -61,12 +61,12 @@
/* ------------------------------- 描述md ------------------------------*/ /* ------------------------------- 描述md ------------------------------*/
editormd("libraries_description", { editormd("libraries_description", {
width: "100%", width: "100%",
height: 210, height: 400,
syncScrolling: "single", syncScrolling: "single",
//你的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.

@ -72,7 +72,7 @@
<div class="break_full_word new_li" id="labraries_editorMd_content" style="box-sizing: border-box"> <div class="break_full_word new_li" id="labraries_editorMd_content" style="box-sizing: border-box">
<textarea style="display:none;"><%= @library.content %></textarea> <textarea style="display:none;"><%= @library.content %></textarea>
</div> </div>
<div class="mt10"> <div class="mt10 pl20">
<%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %> <%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>
</div> </div>
</div> </div>

Loading…
Cancel
Save