Switch to official couch_potato version

This commit is contained in:
2015-07-17 12:44:52 +02:00
parent a8590c7b49
commit af6edfd0aa
9 changed files with 106 additions and 70 deletions
-2
View File
@@ -13,8 +13,6 @@ class Section
has_many :section_elements
has_many :section_areas
attr_protected :supplier_id
validates :title, presence: true
validates :supplier_id, presence: true
+9 -4
View File
@@ -66,13 +66,18 @@ class Supplier
def reset_order_counters_with_spec(spec)
# taken from the couch_potato source since we want a model/custom mix here (hmmmm, something that should be fixed in the couchbase version)
results = CouchPotato::View::ViewQuery.new(
view_spec = {spec.view_name => { map: spec.map_function, reduce: spec.reduce_function} }
list_spec = spec.list_name.nil? ? nil : {spec.list_name => spec.list_function}
lib_spec = nil # do not yet know meaning of this param
query_view = CouchPotato::View::ViewQuery.new(
database.couchrest_database,
spec.design_document,
{spec.view_name => { map: spec.map_function, reduce: spec.reduce_function} },
({spec.list_name => spec.list_function} unless spec.list_name.nil?),
view_spec,
list_spec,
lib_spec,
spec.language
).query_view!(spec.view_parameters)
)
results = query_view.query_view!(spec.view_parameters)
Array.wrap(results['rows']).each do |result|
supplier_id, state = result['key']
case state