diff --git a/SQLyog-11.4.0-0.x64Community.exe b/SQLyog-11.4.0-0.x64Community.exe deleted file mode 100644 index 3260386be..000000000 Binary files a/SQLyog-11.4.0-0.x64Community.exe and /dev/null differ diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index b099a1db5..1b7791ac4 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -54,39 +54,29 @@ class ContestsController < ApplicationController case params[:contest_sort_type] when '0' # modified by longjun - # never use unless and else + # never use unless and else, 将下面重复操作模块化,放在private下 # unless @offset == 0 - if @offset != 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse - end + # if @offset != 0 + # @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + # else + # limit = @contest_count % @limit + # limit = @limit if limit == 0 + # @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.commit') + # end @s_state = 0 when '1' - # modified by longjun - # never use unless and else - # unless @offset == 0 - if @offset != 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse - end + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.created_on') @s_state = 1 - when '2' - # modified by longjun - # never use unless and else - # unless @offset == 0 - if @offset != 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse + # modified by longjun + # 目前只有 0, 1 两个sort_type + # when '2' else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse - end + # end longjun + + @contests = index_page_sort(@offset, @limit, @contest_count, @contests, '') @s_state = 0 end else @@ -723,5 +713,20 @@ class ContestsController < ApplicationController end end + # added by longjun + # 将index页面中分页排序的方法抽离出来 + def index_page_sort(offset, limit, contest_count, contests, contest_sort_by) + # modified by longjun + # never use unless and else + # unless @offset == 0 + if offset != 0 + contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse + else + limit = contest_count % limit + limit = limit if limit == 0 + contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse + end + contests + end end diff --git a/app/views/contest_notification/show.html.erb b/app/views/contest_notification/show.html.erb index 5664d5398..c4dfc737b 100644 --- a/app/views/contest_notification/show.html.erb +++ b/app/views/contest_notification/show.html.erb @@ -14,7 +14,7 @@
<%= f.text_field :deadline, :required => true, diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb index fec4cf24c..2ffecff12 100644 --- a/app/views/contests/_list_projects.html.erb +++ b/app/views/contests/_list_projects.html.erb @@ -78,7 +78,9 @@ <%= l(:label_contest_user) %> <% unless c_project.user.nil? %> - <%= link_to c_project.user.lastname + c_project.user.firstname,user_path(c_project.user) %> + <%= link_to c_project.user.lastname + c_project.user.firstname, + user_path(c_project.user) + %> <% end %> @@ -101,5 +103,7 @@ <% end %> <% end %> -