add chance to new preoject
This commit is contained in:
parent
163cdc8cf7
commit
321f2df0b9
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -4,11 +4,4 @@
|
|||
<%= hidden_field_tag 'project_type', project_type %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||
</div>
|
||||
<div class='font_lighter' style="margin: 0; padding: 0; margin-top: 4px;">
|
||||
<%= if project_type == 0
|
||||
"全站项目搜索。不会搜索私有项目"
|
||||
else
|
||||
"全站课程搜索。"
|
||||
end %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -96,6 +96,7 @@
|
|||
</div>
|
||||
<div class="search-bar">
|
||||
<%= render :partial => "search_project", :locals => {:project_type => 1}%>
|
||||
<div class='font_lighter' style="margin: 0; padding: 0; margin-top: 4px;">全站课程搜索。</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
</div>
|
||||
<div class="search-bar">
|
||||
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
|
||||
<div class='font_lighter' style="margin: 0; padding: 0; margin-top: 4px;">全站项目搜索。不会搜索私有项目</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
@ -111,7 +112,7 @@
|
|||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_miracle_project(10, 7).map do |project| %>
|
||||
<% find_miracle_project(10, 3).map do |project| %>
|
||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||
<div style="float: left;">
|
||||
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
||||
|
|
Loading…
Reference in New Issue