Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
HCSVLAB-MISC: Updates document route to find by handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Anisimoff committed Mar 10, 2016
1 parent 51d0927 commit 84606d3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,19 @@ def primary_text
#
def document
begin

doc = Document.find_by_file_name_and_item_id(params[:filename], params[:id])
# require 'pry'
# binding.pry
# doc = Document.find_by_file_name_and_item_id(params[:filename], params[:id])
item = Item.find_by_handle(params[:id])
doc = item.documents.find_by_file_name(params[:filename])
# check if document exists in JSON metadata from Sesame/Solr
# This is set during Solr indexing based on a variety of metadata from Solr and Sesame
# See add_json_metadata_field in solr_worker.rb
doc = nil if doc.present? and Item.where(id: params[:id]).where("json_metadata like ?","%#{doc.file_path}%").blank?
# require 'pry'
# binding.pry
metadata = Item.where(handle: params[:id]).where("json_metadata like ?","%#{doc.file_path}%")
# doc = nil if doc.present? and Item.where(id: params[:id]).where("json_metadata like ?","%#{doc.file_path}%").blank?
doc = nil if doc.present? and metadata.blank?

if doc.present?

Expand Down

0 comments on commit 84606d3

Please sign in to comment.