Module: NdrError::Finder
- Included in:
- NdrError
- Defined in:
- lib/ndr_error/finder.rb
Overview
Module to help with searching through fingerprints / logs.
Instance Method Summary collapse
- 
  
    
      #find(id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Sends finds through to the fingerprint resource. 
- 
  
    
      #paginate(keywords, page)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Proxy to paginate fingerprint results, filtering them if search keywords have been supplied. 
- #search(keywords) ⇒ Object
Instance Method Details
#find(id) ⇒ Object
Sends finds through to the fingerprint resource.
| 27 28 29 | # File 'lib/ndr_error/finder.rb', line 27 def find(id) Fingerprint.find(id) end | 
#paginate(keywords, page) ⇒ Object
Proxy to paginate fingerprint results, filtering them if search keywords have been supplied.
| 22 23 24 | # File 'lib/ndr_error/finder.rb', line 22 def paginate(keywords, page) search(keywords).paginate(page: page, per_page: Fingerprint.per_page) end | 
#search(keywords) ⇒ Object
| 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # File 'lib/ndr_error/finder.rb', line 4 def search(keywords) scope = Fingerprint.latest_first return scope unless keywords && keywords.any? # Fetch the collection of fingerprint matches: records = scope.filter_by_keywords(keywords).to_a # Add to that fingerprints with log records that matched the search: log_print_ids = Log.not_deleted.filter_by_keywords(keywords).pluck(:error_fingerprintid) scope.where(error_fingerprintid: log_print_ids).find_in_batches do |batch| records.concat batch end order(records) end |