diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 14747821..c0bde5e4 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -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 = 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.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)') - .group('shixun_id').count + + shixun_ids = @shixuns.map(&:id) + @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 course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) @@ -323,4 +327,10 @@ class CompetitionTeamsController < ApplicationController true 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 diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 6ab6d3f6..d60de29c 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -360,7 +360,7 @@ class UsersService g = Gitlab.client g.edit_user(@current_user.gid, :password => params[:new_password]) rescue Exception => e - logger.error "change users password failed! ===> #{e}" + Rails.logger.error "change users password failed! ===> #{e}" end end end diff --git a/app/views/attachments/_from_libraries.html.erb b/app/views/attachments/_from_libraries.html.erb index eb9126a0..fc6aa98b 100644 --- a/app/views/attachments/_from_libraries.html.erb +++ b/app/views/attachments/_from_libraries.html.erb @@ -14,7 +14,7 @@ <% 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') %> <%= number_to_human_size attachment.filesize %> - <%= link_to(''.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= link_to(''.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}][attachment_id]", attachment.id %> @@ -24,7 +24,7 @@ <%= 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(''.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(''.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}" %> <% end %> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 80456091..1247e9cc 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -7,9 +7,11 @@ <% end%> <% if options[:length] %> - <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%> + + <%= link_to_short_attachment attachment,:download => true,:length => options[:length] -%> <% else %> - <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true, :length => 32 -%> + + <%= link_to_short_attachment attachment,:download => true, :length => 32 -%> <% end %> <%if is_float%> diff --git a/app/views/libraries/_form.html.erb b/app/views/libraries/_form.html.erb index e864f743..4ce076d2 100644 --- a/app/views/libraries/_form.html.erb +++ b/app/views/libraries/_form.html.erb @@ -61,12 +61,12 @@ /* ------------------------------- 描述md ------------------------------*/ editormd("libraries_description", { width: "100%", - height: 210, + height: 400, syncScrolling: "single", //你的lib目录的路径,我这边用JSP做测试的 path: "/editormd/lib/", tex: true, - watch:false, + watch:true, toolbarIcons: function () { // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. diff --git a/app/views/libraries/show.html.erb b/app/views/libraries/show.html.erb index 6889e49d..03ad3f11 100644 --- a/app/views/libraries/show.html.erb +++ b/app/views/libraries/show.html.erb @@ -72,7 +72,7 @@
-
+
<%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>