Merge branch 'szzh' into dev_zanle

Conflicts:
	app/models/attachment.rb
	db/schema.rb
This commit is contained in:
lizanle 2015-11-27 18:47:19 +08:00
parent 582cd6f5d4
commit 96290ad975
3 changed files with 1929 additions and 1916 deletions

View File

@ -400,19 +400,31 @@ class Course < ActiveRecord::Base
# end
def create_course_ealasticsearch_index
if self.is_public == 1
self.__elasticsearch__.index_document
self.__elasticsearch__.index_document
end
end
def update_course_ealasticsearch_index
if self.is_public == 1
self.__elasticsearch__.update_document
if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
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_course_ealasticsearch_index
if self.is_public == 1
self.__elasticsearch__.delete_document
end
def delete_course_ealasticsearch_index
begin
self.__elasticsearch__.delete_document
rescue => e
end
end
end

View File

@ -243,7 +243,7 @@ class User < Principal
after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index
# end
# 更新邮箱用户或用户名的同事,同步更新邀请信息
after_update :update_invite_list,:upadte_user_ealasticsearch_index
after_update :update_invite_list,:update_user_ealasticsearch_index
include Trustie::Gitlab::ManageUser
@ -1161,6 +1161,23 @@ class User < Principal
end
end
def create_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.index_document
end
end
def update_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.update_document
end
end
def delete_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.delete_document
end
end
end
class AnonymousUser < User
@ -1196,21 +1213,6 @@ class AnonymousUser < User
false
end
def create_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.index_document
end
end
def update_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.update_document
end
end
def delete_user_ealasticsearch_index
if self.id != 2 && self.id != 4
self.__elasticsearch__.delete_document
end
end
end
# Delete the previous articles index in Elasticsearch

File diff suppressed because it is too large Load Diff