Merge branch 'szzh' into dev_zanle
Conflicts: app/models/attachment.rb db/schema.rb
This commit is contained in:
parent
582cd6f5d4
commit
96290ad975
|
@ -400,19 +400,31 @@ class Course < ActiveRecord::Base
|
||||||
# end
|
# end
|
||||||
def create_course_ealasticsearch_index
|
def create_course_ealasticsearch_index
|
||||||
if self.is_public == 1
|
if self.is_public == 1
|
||||||
self.__elasticsearch__.index_document
|
self.__elasticsearch__.index_document
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def update_course_ealasticsearch_index
|
def update_course_ealasticsearch_index
|
||||||
if self.is_public == 1
|
if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
|
||||||
self.__elasticsearch__.update_document
|
begin
|
||||||
|
self.__elasticsearch__.update_document
|
||||||
|
rescue => e
|
||||||
|
self.__elasticsearch__.index_document
|
||||||
|
end
|
||||||
|
else #如果是更新成为私有的,那么索引就要被删除
|
||||||
|
begin
|
||||||
|
self.__elasticsearch__.delete_document
|
||||||
|
rescue => e
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def delete_course_ealasticsearch_index
|
|
||||||
|
|
||||||
if self.is_public == 1
|
def delete_course_ealasticsearch_index
|
||||||
self.__elasticsearch__.delete_document
|
begin
|
||||||
end
|
self.__elasticsearch__.delete_document
|
||||||
|
rescue => e
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ class User < Principal
|
||||||
after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index
|
after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index
|
||||||
# end
|
# end
|
||||||
# 更新邮箱用户或用户名的同事,同步更新邀请信息
|
# 更新邮箱用户或用户名的同事,同步更新邀请信息
|
||||||
after_update :update_invite_list,:upadte_user_ealasticsearch_index
|
after_update :update_invite_list,:update_user_ealasticsearch_index
|
||||||
|
|
||||||
include Trustie::Gitlab::ManageUser
|
include Trustie::Gitlab::ManageUser
|
||||||
|
|
||||||
|
@ -1161,6 +1161,23 @@ class User < Principal
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
class AnonymousUser < User
|
class AnonymousUser < User
|
||||||
|
@ -1196,21 +1213,6 @@ class AnonymousUser < User
|
||||||
false
|
false
|
||||||
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
|
end
|
||||||
|
|
||||||
# Delete the previous articles index in Elasticsearch
|
# Delete the previous articles index in Elasticsearch
|
||||||
|
|
3785
db/schema.rb
3785
db/schema.rb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue