This commit is contained in:
yanxd 2014-01-13 21:24:01 +08:00
parent 95e77464ad
commit 308df9eda5
1 changed files with 16 additions and 16 deletions

View File

@ -9,15 +9,15 @@ class StoresController < ApplicationController
# include ActsAsTaggableOn::TagsHelper
LIMIT = 20 unless const_defined?(:LIMIT)
def index
@projects_attach = project_classification(0).take(LIMIT)
@courses_attach = project_classification(1).take(LIMIT)
# @projects_attach = Attachment.includes(:projects).where("projects.project_type=?", 0).
# reorder("#{Attachment.table_name}.created_on DESC").
# limit(LIMIT)
# @projects_attach = project_classification(0).take(LIMIT)
# @courses_attach = project_classification(1).take(LIMIT)
@projects_attach = Attachment.includes(:project).where("projects.project_type=?", 0).
reorder("#{Attachment.table_name}.downloads DESC").
limit(LIMIT)
# @courses_attach = Attachment.includes(:projects).where("projects.project_type=?", 1).
# reorder("#{Attachment.table_name}.created_on DESC").
# limit(LIMIT)
@courses_attach = Attachment.includes(:project).where("projects.project_type=?", 1).
reorder("#{Attachment.table_name}.downloads DESC").
limit(LIMIT)
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
reorder("created_on DESC").
limit(LIMIT)
@ -31,16 +31,16 @@ class StoresController < ApplicationController
private
def project_classification project_type=0
pro_attach = Attachment.joins("LEFT JOIN projects ON attachments.container_id = projects.id").
pro_attach = Attachment.joins("LEFT JOIN projects ON attachments.container_id = projects.id").
where("projects.project_type=#{project_type}").
reorder("downloads").
reorder("downloads DESC").
limit(LIMIT)
doc_attach = join_tools_project "documents", project_type
issue_attach = join_tools_project "issues", project_type
mess_attach = []#join_tools_project "messages", project_type
news_attach = join_tools_project "news", project_type
vers_attach = join_tools_project "versions", project_type
wiki_attach = []#join_tools_project "wiki_pages", project_type
doc_attach = join_tools_project "documents", project_type
issue_attach = join_tools_project "issues", project_type
mess_attach = []#join_tools_project "messages", project_type
news_attach = join_tools_project "news", project_type
vers_attach = join_tools_project "versions", project_type
wiki_attach = []#join_tools_project "wiki_pages", project_type
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
tmp.sort { |a, b| b.downloads <=> a.downloads }