improvements
This commit is contained in:
@@ -18,11 +18,23 @@ class Order
|
||||
emit(doc.supplier_id, 1);
|
||||
}
|
||||
}], reduce_function: '_sum'
|
||||
view :active_for_supplier_and_section_view, type: :custom, map_function: %[function(doc){
|
||||
if(doc.ruby_class == 'Order' && (doc.state == 'placed' || doc.state == 'active')){
|
||||
emit([doc.supplier_id, doc.section_id], 1);
|
||||
}
|
||||
}], reduce_function: '_sum'
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
|
||||
# Return all currently active orders for a given supplier
|
||||
def self.active_for_supplier(supplier_id)
|
||||
database.view(active_for_supplier_view(key: supplier_id, reduce: false, include_docs: true))
|
||||
end
|
||||
|
||||
# Return all currently active orders for a given section
|
||||
def self.active_for_supplier_and_section(supplier, section_id)
|
||||
database.view(active_for_supplier_and_section_view(key: [supplier.id, section_id], reduce: false, include_docs: true))
|
||||
end
|
||||
|
||||
def table_number
|
||||
list.table.number
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user