ruby on rails - Rails4 - Combining identical orders into batches -
i need architectural advice. have ordering system. users can order products variety. each order can have 1 type of product, quantity may differ. order feed looks this:
order 1 - product#1 - qty: 5, created_at: 01/01 order 2 - product#5 - qty: 12, created_at: 01/02 order 3 - product#7 - qty: 1, created_at: 01/05 however when user orders several identical products @ different times, list looks this
*order 1 - product#1 - qty: 1, created_at: 01/01 order 2 - product#5 - qty: 12, created_at: 01/03 *order 3 - product#1 - qty: 3, created_at: 01/05 this creates unwanted duplication in views (and manager has call several times order stuff) , struggling figure out how combine these orders batch, this:
*order 1,3 - product#1 - qty: 4 (1+3), created_at: 01/01, 01/05 order 2 - product#5 - qty: 12, created_at: 01/03 would love hear suggestions
i join products orders ordered product_id. walk through collection , display 1 line if product_id changes.
this way whole report done single query instead of 1+n query. :)
Comments
Post a Comment