Skip to content

Commit

Permalink
filename fuzzy search
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Oct 17, 2024
1 parent 80db48d commit 5a2d2f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/controllers/collection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ def find_by_localid(collection_ark, term)
end

def find_by_file_name(collection_ark, term)
if term =~ /\*/
where = 'inv_files.pathname like ?'
val = "producer/#{term.gsub('*', '%')}"
else
where = 'inv_files.pathname = ?'
val = "producer/#{term}"
end
InvObject
.joins(:inv_collections, :inv_files)
.where('inv_collections.ark = ?', collection_ark)
.where('inv_files.pathname = ?', "producer/#{term}")
.where(where, val)
.includes(:inv_versions)
.quickloadhack
.limit(10)
Expand Down
9 changes: 8 additions & 1 deletion app/controllers/owner_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ def find_by_localid(owner, term)
end

def find_by_file_name(owner, term)
if term =~ /\*/
where = 'inv_files.pathname like ?'
val = "producer/#{term.gsub('*', '%')}"
else
where = 'inv_files.pathname = ?'
val = "producer/#{term}"
end
InvObject
.joins(:inv_owner, :inv_files)
.where('inv_owners.ark = ?', owner.ark)
.where('inv_files.pathname = ?', "producer/#{term}")
.where(where, val)
.includes(:inv_versions)
.quickloadhack
.limit(10)
Expand Down

0 comments on commit 5a2d2f2

Please sign in to comment.