Class: WinewooCore::Services::Finders::Wines::AllWinesFinder

Inherits:
WinesFinder
  • Object
show all
Defined in:
lib/winewoo_core/services/finders/wines/all_wines_finder.rb

Instance Method Summary collapse

Methods inherited from WinesFinder

#initialize

Constructor Details

This class inherits a constructor from WinewooCore::Services::Finders::Wines::WinesFinder

Instance Method Details

#findObject



4
5
6
7
8
9
10
11
12
# File 'lib/winewoo_core/services/finders/wines/all_wines_finder.rb', line 4

def find
  query = WinewooCore::Repositories::Mongo::Queries::WineQuery.new(Wine.unscoped).officials
  query = query.from_interpro(@interpro.id) if @interpro
  query = @filters.scope_recents ? query.order_by(updated_at: :desc) : query.order_by(created_at: :asc)
  wines = query.page(@page || 1)
    .per(@per_page || Kaminari::config.default_per_page)

  return wines, nil, query.count
end