From 321f2df0b91ab1ab32dbb997a044eb9d08b572ec Mon Sep 17 00:00:00 2001 From: xianbo Date: Mon, 24 Mar 2014 17:12:28 +0800 Subject: [PATCH] add chance to new preoject --- app/helpers/welcome_helper.rb | 7 +++---- app/views/welcome/_search_project.html.erb | 7 ------- app/views/welcome/course.html.erb | 1 + app/views/welcome/index.html.erb | 3 ++- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index fd00c83e2..9fc768d9c 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -64,12 +64,11 @@ module WelcomeHelper (c1.take(max)+c2).take(sum) end - def find_miracle_project(sum=10, max_rate=7) + def find_miracle_project(sum, max_rate) max = sum*(max_rate.to_f/10) c1 = find_new_project(sum).to_a.dup c2 = find_all_hot_project(sum).to_a.dup - c2 = c2 - c1 - (c1.take(max)+c2).take(sum) + (c2.take(sum-max)+c1.take(max)).take(sum) end def find_new_course limit=15 @@ -77,7 +76,7 @@ module WelcomeHelper end def find_new_project limit=15 - Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 0).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all + Project.visible.where("#{Project.table_name}.project_type = ? ", 0).order("#{Project.table_name}.updated_on DESC, #{Project.table_name}.created_on DESC").limit(limit).all end diff --git a/app/views/welcome/_search_project.html.erb b/app/views/welcome/_search_project.html.erb index df5ce7ad3..61770cace 100644 --- a/app/views/welcome/_search_project.html.erb +++ b/app/views/welcome/_search_project.html.erb @@ -4,11 +4,4 @@ <%= hidden_field_tag 'project_type', project_type %> <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> -
- <%= if project_type == 0 - "全站项目搜索。不会搜索私有项目" - else - "全站课程搜索。" - end %> -
<% end %> \ No newline at end of file diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 734568c7d..363aa8130 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -96,6 +96,7 @@
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index c88f7e0e2..af2741a5b 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -96,6 +96,7 @@
@@ -111,7 +112,7 @@ <%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %>