Browse Source

Merge pull request #118 from lexintegritastech/enhance-searchable-in-annotations

Enhanc`searchable` in `annotations`
pull/119/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
8308ce3934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/models/annotation.rb

14
app/models/annotation.rb

@ -35,9 +35,17 @@ class Annotation < ApplicationRecord
integer :document_id
integer :doctrine_id
join(:library_rank, target: Cdao::Document, type: :integer, join: { from: :id, to: :document_id })
join(:search_year, target: Cdao::Document, type: :integer, join: { from: :id, to: :document_id })
join(:search_doc_date, target: Cdao::Document, type: :date, join: { from: :id, to: :document_id })
integer :library_rank do
document.library.rank
end
integer :search_year do
document.year.present? && document.year > 0 ? document.year : (document.doc_date.try :year)
end
date :search_doc_date do
document.doc_date.presence || Date.new(year.presence || 0)
end
date :created_at
date :updated_at

Loading…
Cancel
Save