From 43064c4bc24726776cd645a519fc9c2b0c0ec58b Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Sat, 19 Apr 2014 13:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=9E=E8=B5=9B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E9=A6=96=E9=A1=B5=E4=B8=AD=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=EF=BC=9A=E6=97=A2=E6=9C=89=E6=97=A7=E7=9A=84?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=8F=88=E6=9C=89=E6=96=B0=E7=9A=84=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/welcome_helper.rb | 17 ++++++++++++++++- app/views/welcome/contest.html.erb | 7 +++---- 2 files changed, 19 insertions(+), 5 deletions(-) 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/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 38afd6091..27ab04e1a 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -138,7 +138,7 @@ <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
- <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> + <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[8]) %>
  • @@ -146,7 +146,7 @@
    - <%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> + <%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
    @@ -154,8 +154,7 @@

    - + 发布时间:<%=format_time contest.created_on %>