made the pager return keys in order
This commit is contained in:
parent
fbccbd73e0
commit
15884184aa
26
lib/pager.rb
26
lib/pager.rb
|
@ -75,13 +75,27 @@ class CouchRest
|
||||||
startkey = endkey
|
startkey = endkey
|
||||||
end
|
end
|
||||||
|
|
||||||
grouped = rows.group_by{|r|r['key']}
|
# grouped = rows.group_by{|r|r['key']}
|
||||||
grouped.each do |k, rs|
|
# grouped.each do |k, rs|
|
||||||
vs = rs.collect{|r|r['value']}
|
# vs = rs.collect{|r|r['value']}
|
||||||
yield(k,vs)
|
# yield(k,vs)
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
key = :begin
|
||||||
|
values = []
|
||||||
|
|
||||||
|
rows.each do |r|
|
||||||
|
if key != r['key']
|
||||||
|
# we're on a new key, yield the old first and then reset
|
||||||
|
yield(key, values) if key != :begin
|
||||||
|
key = r['key']
|
||||||
|
values = []
|
||||||
|
end
|
||||||
|
# keep accumulating
|
||||||
|
values << r['value']
|
||||||
|
end
|
||||||
|
yield(key, values)
|
||||||
|
|
||||||
# lastprocessedkey = rows.last['key']
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue