搜索课程

This commit is contained in:
yuanke 2016-10-09 15:05:50 +08:00
parent fdcb13a3de
commit 5d5306dede
3 changed files with 12 additions and 3 deletions

View File

@ -179,7 +179,7 @@ class WelcomeController < ApplicationController
content:{}
}
}
},[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
},[User,Syllabus,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
when 'user'
@users = User.search(@name).page(params[:page] || 1).per(20)
when 'syllabus'
@ -251,7 +251,7 @@ class WelcomeController < ApplicationController
content:{}
}
}
},[User,Course,Attachment,Project,Memo] ).results.total
},[User,Syllabus,Course,Attachment,Project,Memo] ).results.total
# search_type = params[:search_type].to_sym unless search_condition.blank?
# search_by = params[:search_by]
#

View File

@ -33,6 +33,8 @@ class Syllabus < ActiveRecord::Base
after_create :create_syllabus_ealasticsearch_index
before_destroy :delete_syllabus_ealasticsearch_index
scope :indexable,lambda { where(nil) }#用于elastic建索引的scope
scope :like, lambda {|arg|
if arg.blank?
where(nil)

View File

@ -22,6 +22,13 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
task :importsyllabus => :environment do
ENV['CLASS']='Syllabus'
ENV['SCOPE']='indexable'
ENV['FORCE']='y'
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
task :importattachment => :environment do
ENV['CLASS']='Attachment'
ENV['SCOPE']='indexable'
@ -38,5 +45,5 @@ namespace :importer do
end
desc "Run all tasks"
task :all => [:importuser,:importproject,:importcourse,:importattachment,:importmemo]
task :all => [:importuser,:importproject,:importsyllabus,:importcourse,:importattachment,:importmemo]
end