Merge branch 'szzh' into dev_zanle

Conflicts:
	app/models/attachment.rb
	db/schema.rb
This commit is contained in:
lizanle 2015-11-27 19:02:07 +08:00
parent 96290ad975
commit e728dd55eb
1 changed files with 17 additions and 5 deletions

View File

@ -1217,18 +1217,30 @@ class Project < ActiveRecord::Base
def create_project_ealasticsearch_index
if self.is_public == 1
if self.is_public
self.__elasticsearch__.index_document
end
end
def update_project_ealasticsearch_index
if self.is_public == 1
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
begin
self.__elasticsearch__.update_document
rescue => e
self.__elasticsearch__.index_document
end
else #如果是更新成为私有的,那么索引就要被删除
begin
self.__elasticsearch__.delete_document
rescue => e
end
end
end
def delete_project_ealasticsearch_index
if self.is_public == 1
begin
self.__elasticsearch__.delete_document
rescue => e
end
end