Class: Query::CatalogItemQuery
- Inherits:
-
BaseQuery
- Object
- BaseQuery
- Query::CatalogItemQuery
- Defined in:
- app/services/query/catalog_item_query.rb
Instance Method Summary collapse
-
#initialize(relation = nil) ⇒ CatalogItemQuery
constructor
A new instance of CatalogItemQuery.
- #low_stock_for_google_feed(stock_threshold: 2) ⇒ Object
Constructor Details
#initialize(relation = nil) ⇒ CatalogItemQuery
Returns a new instance of CatalogItemQuery.
2 3 4 |
# File 'app/services/query/catalog_item_query.rb', line 2 def initialize(relation = nil) super(relation || CatalogItem.all) end |
Instance Method Details
#low_stock_for_google_feed(stock_threshold: 2) ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/services/query/catalog_item_query.rb', line 6 def low_stock_for_google_feed(stock_threshold: 2) @relation.joins(store_item: :item).joins(:catalog) .for_google_feed .where(StoreItem[:qty_on_hand].lteq(stock_threshold)).where(StoreItem[:location].eq('AVAILABLE')) .select('items.id,items.name as item_name,items.sku as item_sku,catalog_items.id,catalogs.name as catalog_name,store_items.qty_on_hand') .order('catalog_name, item_sku') end |