Merge branch 'hjq_new_course' of http://git.trustie.net/jacknudt/trustieforge into hjq_new_course

This commit is contained in:
huang 2015-12-10 16:09:42 +08:00
commit fbba933a46
2 changed files with 29 additions and 22 deletions

View File

@ -115,7 +115,7 @@ class Course < ActiveRecord::Base
where(" LOWER(name) LIKE :p ", :p => pattern)
end
}
scope :indexable,lambda { where('is_public = 1') }
scope :indexable,lambda { where('is_public = 1 and is_delete = 0') }
def self.search(query)
__elasticsearch__.search(
{
@ -400,12 +400,12 @@ class Course < ActiveRecord::Base
# __elasticsearch__.delete_document
# end
def create_course_ealasticsearch_index
if self.is_public == 1
if self.is_public == 1 and self.is_delete == 0 #公开 和 没有被删除的课程才被索引
self.__elasticsearch__.index_document
end
end
def update_course_ealasticsearch_index
if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
if self.is_public == 1 and self.is_delete == 0 #如果是初次更新成为公开或者恢复被删除的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
begin
self.__elasticsearch__.update_document
rescue => e

View File

@ -459,7 +459,7 @@ ActiveRecord::Schema.define(:version => 20151208015409) do
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete"
t.integer "is_delete", :default => 0
end
create_table "custom_fields", :force => true do |t|
@ -544,26 +544,23 @@ ActiveRecord::Schema.define(:version => 20151208015409) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :primary_key => "Num", :force => true do |t|
t.string "Defect", :limit => 50
t.string "Category", :limit => 50
t.string "File"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
create_table "dts", :force => true do |t|
t.string "IPLineCode"
t.string "Description"
t.text "PreConditions", :limit => 2147483647
t.text "TraceInfo", :limit => 2147483647
t.text "Code", :limit => 2147483647
t.string "Num"
t.string "Variable"
t.string "TraceInfo"
t.string "Method"
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.integer "project_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "editor_of_documents", :force => true do |t|
@ -901,6 +898,16 @@ ActiveRecord::Schema.define(:version => 20151208015409) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"