ADD model concerns

This commit is contained in:
Jasder 2019-11-14 15:33:07 +08:00
parent 3bcd7c408a
commit 1e05bfac23
8 changed files with 8 additions and 43 deletions

View File

@ -17,7 +17,6 @@
require "digest/md5"
require "fileutils"
require 'elasticsearch/model'
class Attachment < ActiveRecord::Base
belongs_to :container, :polymorphic => true
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
@ -48,12 +47,7 @@ class Attachment < ActiveRecord::Base
include ApplicationHelper
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :filename, analyzer: 'smartcn',index_options: 'offsets'

View File

@ -4,7 +4,7 @@ module EsSearchable
included do
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
document_type 'doc' if Rails.env.production? # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init

View File

@ -1,5 +1,4 @@
#coding=utf-8
require 'elasticsearch/model'
class Course < ActiveRecord::Base
include Redmine::SafeAttributes
@ -10,12 +9,7 @@ class Course < ActiveRecord::Base
STATUS_ARCHIVED = 9
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'

View File

@ -1,4 +1,3 @@
require 'elasticsearch/model'
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
@ -15,12 +14,7 @@ class Memo < ActiveRecord::Base
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: {
number_of_shards: 5 ,
analysis: {

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'elasticsearch/model'
class Project < ActiveRecord::Base
include Redmine::SafeAttributes
ProjectType_project = 0
@ -31,12 +30,7 @@ class Project < ActiveRecord::Base
# Specific overidden Activities
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'

View File

@ -1,15 +1,9 @@
# encoding: utf-8
require 'elasticsearch/model'
class Syllabus < ActiveRecord::Base
include Redmine::SafeAttributes
include ApplicationHelper
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :title, analyzer: 'smartcn',index_options: 'offsets'

View File

@ -16,7 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require "digest/sha1"
require 'elasticsearch/model'
class User < Principal
TEACHER = 0
STUDENT = 1
@ -26,12 +25,7 @@ class User < Principal
include Redmine::SafeAttributes
seems_rateable_rater
#elasticsearch
include Elasticsearch::Model
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
include EsSearchable
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :login, analyzer: 'smartcn',index_options: 'offsets'

View File

@ -33,6 +33,7 @@ module RedmineApp
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers)
config.autoload_paths += Dir[ Rails.root.join('app', 'models', "concerns", '**/') ]
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]