|
|
@ -9,10 +9,10 @@ class StoresController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
def search
|
|
|
|
def search
|
|
|
|
name = params[:name] ||= ''
|
|
|
|
name = params[:name] ||= ''
|
|
|
|
@searched_attach = Attachment.includes(:project).where("projects.is_public = ? AND filename LIKE '%"<< name <<"%' ", 1)
|
|
|
|
# 按文件名搜索
|
|
|
|
# @searched_attach = Attachment.all[0..20]
|
|
|
|
result = Attachment.includes(:project).where("projects.is_public = ? AND filename LIKE '%" << name << "%' ", 1)
|
|
|
|
@searched_attach.take 20
|
|
|
|
@searched_attach = result
|
|
|
|
# reutrn @searched_attach
|
|
|
|
return @searched_attach
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
LIMIT = 12 unless const_defined?(:LIMIT)
|
|
|
|
LIMIT = 12 unless const_defined?(:LIMIT)
|
|
|
@ -47,12 +47,12 @@ class StoresController < ApplicationController
|
|
|
|
where("projects.project_type=#{project_type}").
|
|
|
|
where("projects.project_type=#{project_type}").
|
|
|
|
reorder("downloads DESC").
|
|
|
|
reorder("downloads DESC").
|
|
|
|
limit(LIMIT)
|
|
|
|
limit(LIMIT)
|
|
|
|
doc_attach = join_tools_project "documents", project_type
|
|
|
|
doc_attach = join_tools_project Document, project_type
|
|
|
|
issue_attach = join_tools_project "issues", project_type
|
|
|
|
issue_attach = join_tools_project Issue, project_type
|
|
|
|
mess_attach = []#join_tools_project "messages", project_type
|
|
|
|
mess_attach = []#join_tools_project Message, project_type
|
|
|
|
news_attach = join_tools_project "news", project_type
|
|
|
|
news_attach = join_tools_project News"news", project_type
|
|
|
|
vers_attach = join_tools_project "versions", project_type
|
|
|
|
vers_attach = join_tools_project Version"versions", project_type
|
|
|
|
wiki_attach = []#join_tools_project "wiki_pages", project_type
|
|
|
|
wiki_attach = []#join_tools_project WikiPage, project_type
|
|
|
|
|
|
|
|
|
|
|
|
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
|
|
|
|
tmp = pro_attach+doc_attach+issue_attach+mess_attach+news_attach+vers_attach+wiki_attach
|
|
|
|
tmp.sort { |a, b| b.downloads <=> a.downloads }
|
|
|
|
tmp.sort { |a, b| b.downloads <=> a.downloads }
|
|
|
@ -64,9 +64,9 @@ class StoresController < ApplicationController
|
|
|
|
limit(LIMIT)
|
|
|
|
limit(LIMIT)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def str_join_table tableName
|
|
|
|
def str_join_table tableClass
|
|
|
|
str = "LEFT JOIN #{tableName} ON attachments.container_id = #{tableName}.id
|
|
|
|
str = "LEFT JOIN #{tableClass.table_name} ON attachments.container_id = #{tableClass.table_name}.id
|
|
|
|
LEFT JOIN projects ON #{tableName}.project_id = projects.id"
|
|
|
|
LEFT JOIN projects ON #{tableClass.table_name}.project_id = projects.id"
|
|
|
|
str
|
|
|
|
str
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|