paging done, needs some additional refactoring
This commit is contained in:
@@ -10,7 +10,13 @@ class Item < ActiveRecord::Base
|
||||
|
||||
# TODO: change "best selling" algorithm when get some data - currently it's only sorted by earnings
|
||||
scope :best_selling, -> (offset, limit) { where(:on_display => true).order("(list_price - current_input_price) DESC").limit(limit).offset(offset) }
|
||||
|
||||
scope :best_selling_in_sub_category, -> (sub_category_id, offset, limit) { best_selling(offset, limit).where(sub_category_id: sub_category_id) }
|
||||
|
||||
scope :best_selling_in_category, -> (category_id, offset, limit) { best_selling(offset, limit).joins( sub_category: [:category] ).where(["category_id = ?", category_id]) }
|
||||
|
||||
scope :best_selling_in_section, -> (section_id, offset, limit) { best_selling(offset, limit).joins( sub_category: [category: [ :section ]] ).where( ["section_id = ?", section_id] ) }
|
||||
|
||||
scope :all_in_category, -> (category_id) { where(on_display: true).joins( sub_category: [:category]).where(["category_id = ?", category_id]) }
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class SubCategory < ActiveRecord::Base
|
||||
belongs_to :category
|
||||
has_many :filter_criterias, as: :owner
|
||||
has_many :items
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user