diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 10e8a4471..9970ee9c6 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -98,7 +98,14 @@ module WelcomeHelper end def find_all_hot_contest limit=10 - Contest.reorder("created_on DESC").all.take limit + # Contest.reorder("created_on DESC").all.take limit + mix_bid = [] + mix_bid += Contest.reorder("created_on DESC").take(limit).to_a + mix_bid += Bid.visible.where('reward_type = ?', 2).reorder('bids.created_on desc').take(limit).to_a + mix_bid.sort do |older, newer| + newer.created_on - older.created_on + end + mix_bid.take limit end def find_all_hot_softapplication limit=10 @@ -224,6 +231,10 @@ module WelcomeHelper def sort_contest_by_hot sort_bid_by_hot_rails 2 end +#new added by linchun + def sort_contest_by_time + sort_bid_by_time 2 + end #取得所有活动 def find_all_activities limit=6 @@ -278,6 +289,10 @@ module WelcomeHelper Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit) end + def sort_bid_by_time reward_type, limit = 10 + Bid.visible.where('reward_type = ?', reward_type).reorder('bids.created_on desc').limit(limit) + end + def find_all_event_type event case event.event_type when 'news' diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index 4fb2865c8..fb3ddd115 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -6,7 +6,7 @@
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path') %> | +<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %> | ||
@@ -18,8 +18,8 @@ | |||
<%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to(contest.contesting_projects.count, show_project_contest_path(contest)) %>) - <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest)) %>) + | <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to(contest.contesting_projects.count, show_project_contest_path(contest), :target => "_blank") %>) + <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest), :target => "_blank") %>) | ||
-
-
|
+