removed redundant ribica name from subfolders
This commit is contained in:
4
front-api/models/category.rb
Normal file
4
front-api/models/category.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Category < ActiveRecord::Base
|
||||
has_many :sub_categories
|
||||
belongs_to :section
|
||||
end
|
||||
12
front-api/models/item.rb
Normal file
12
front-api/models/item.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Item < ActiveRecord::Base
|
||||
belongs_to :unit
|
||||
has_many :multi_media_descriptions
|
||||
belongs_to :sub_category
|
||||
|
||||
# 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] ) }
|
||||
|
||||
end
|
||||
3
front-api/models/media_type.rb
Normal file
3
front-api/models/media_type.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class MediaType < ActiveRecord::Base
|
||||
has_many :multi_media_descriptions
|
||||
end
|
||||
5
front-api/models/multi_media_description.rb
Normal file
5
front-api/models/multi_media_description.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class MultiMediaDescription < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
belongs_to :media_type
|
||||
|
||||
end
|
||||
3
front-api/models/section.rb
Normal file
3
front-api/models/section.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Section < ActiveRecord::Base
|
||||
has_many :categories
|
||||
end
|
||||
5
front-api/models/sub_category.rb
Normal file
5
front-api/models/sub_category.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class SubCategory < ActiveRecord::Base
|
||||
belongs_to :category
|
||||
end
|
||||
|
||||
|
||||
2
front-api/models/unit.rb
Normal file
2
front-api/models/unit.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Unit < ActiveRecord::Base
|
||||
end
|
||||
Reference in New Issue
Block a user