Class: WinewooCore::Services::Finders::Wines::FiltersWinesFinder
- Inherits:
-
WinesFinder
- Object
- WinesFinder
- WinewooCore::Services::Finders::Wines::FiltersWinesFinder
- Defined in:
- lib/winewoo_core/services/finders/wines/filters_wines_finder.rb
Instance Method Summary collapse
Methods inherited from WinesFinder
Constructor Details
This class inherits a constructor from WinewooCore::Services::Finders::Wines::WinesFinder
Instance Method Details
#find ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/winewoo_core/services/finders/wines/filters_wines_finder.rb', line 4 def find search = clean_search_params interpro_id = (@interpro && @interpro.id) || search[:interpro_id] # TODO UNOFFICIALS # query = WinewooCore::Repositories::Mongo::Queries::WineQuery.new.officials.published query = @interpro ? WinewooCore::Repositories::Mongo::Queries::WineQuery.new.officials.published : WinewooCore::Repositories::Mongo::Queries::WineQuery.new.officials.published query = query.with_appelation(search[:appelations] || search[:aoc]) .with_colors(search[:colors]) .with_grapes(search[:grapes]) .with_storage_duration(search[:storage_duration]) .with_tasting_opportunities(search[:tasting_opportunities]) query = query.from_interpro(interpro_id) if interpro_id criterions = (search[:flavors] || []) .concat(search[:entries] || []) .concat(search[:dishes] || []) .concat(search[:desserts] || []) .concat(search[:cheeses] || []) query = query.full_text_search(criterions) unless criterions.empty? wines = query.page(@page || 1) .per(@per_page || Kaminari::config.default_per_page) return wines, "advanced_search", query.count end |