Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use key streaming for count, now that it works right over HTTP.

  • Loading branch information...
commit f9b022c2e5d5c403efbcb2bc09eeb8d17b60e1d6 1 parent 25ba9fc
Kyle Kingsbury authored
Showing with 7 additions and 16 deletions.
  1. +7 −16 lib/risky.rb
23 lib/risky.rb
View
@@ -84,22 +84,13 @@ def self.cast(data)
casted
end
- # Counts the number of models via MR
- def self.count
- map("
- function(v) {
- return [1];
- };
- ").reduce("
- function(counts, arg) {
- return [
- counts.reduce(
- function(acc, value) {
- return acc + value
- }, 0)
- ];
- }
- ", :keep => true).run.first
+ # Counts the number of values in the bucket via key streaming
+ def self.count(opts = {:reload => true})
+ count = 0
+ bucket.keys(opts) do |keys|
+ count += keys.length
+ end
+ count
end
# Returns true when record deleted.
Please sign in to comment.
Something went wrong with that request. Please try again.