yaowan
This commit is contained in:
parent
90f1d3c528
commit
d357541bb8
|
@ -7,12 +7,20 @@ class StoresController < ApplicationController
|
||||||
def search
|
def search
|
||||||
name = params[:name] ||= ''
|
name = params[:name] ||= ''
|
||||||
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||||
# 按文件名搜索
|
|
||||||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%").
|
result = find_public_attache name
|
||||||
|
@searched_attach = paginateHelper result
|
||||||
|
@result_all_count = result.count;
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_public_attache keywords
|
||||||
|
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
|
||||||
|
# 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。
|
||||||
|
# 现在还木有思路 药丸
|
||||||
|
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
|
||||||
reorder("created_on DESC")
|
reorder("created_on DESC")
|
||||||
|
|
||||||
result = resultSet.to_a.dup
|
result = resultSet.to_a.dup
|
||||||
@result_all_count = result.count;
|
|
||||||
|
|
||||||
resultSet.to_a.map { |res|
|
resultSet.to_a.map { |res|
|
||||||
if(res.container.nil? ||
|
if(res.container.nil? ||
|
||||||
|
@ -21,13 +29,10 @@ class StoresController < ApplicationController
|
||||||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
# logger.debug("=====================================#{result.include? res}")
|
|
||||||
# logger.debug("=====================================#{res}")
|
|
||||||
result.delete(res)
|
result.delete(res)
|
||||||
# logger.debug("=====================================#{result.include? res}")
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@searched_attach = paginateHelper result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||||
|
|
Loading…
Reference in New Issue