improvements

This commit is contained in:
2012-09-06 14:49:22 +02:00
parent 27d7fd304e
commit 161da7a82d
18 changed files with 209 additions and 81 deletions
+12
View File
@@ -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