optimization project helper.

This commit is contained in:
yanxd 2013-11-22 14:34:05 +08:00
parent 5de8e1c2f2
commit ae1fe0027a
2 changed files with 8 additions and 2 deletions

View File

@ -262,7 +262,12 @@ module ProjectsHelper
# @projects_status = @projects_status.reorder('grade').all.reverse
# Project.joins(@projects_status).limit(10)
limit = 10
Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ")
#Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ")
Project.find_by_sql("
SELECT p.id, p.name, p.description, p.identifier, t.project_id
FROM projects AS p RIGHT OUTER JOIN (
SELECT project_id,grade FROM project_statuses
WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
end
end

View File

@ -100,13 +100,14 @@
}
}
</script>
<!-- info display block -->
<%= stylesheet_link_tag 'welcome' %>
<div class="body_resize">
<div class="right">
<div class="home"><%= l :label_hot_project%></div>
<% find_all_hot_project.map do |project| break if(project == find_all_hot_project[5]) %>
<div class="project">
<%=link_to( project.name, project_path(project), :class => "nowrap" )%>
<%=link_to( project.name, project_path(project.project_id), :class => "nowrap" )%>
<p><%= project.description %></p>
<!-- span class="grey"><strong><em> </em></strong></span -->
</div>