Permalink
Browse files

Update lib/ruote/mon/storage.rb

  • Loading branch information...
1 parent e96403e commit 4fc442280f8ad8084e18d8d35524dc08bc083420 @jjmay committed Apr 29, 2012
Showing with 19 additions and 1 deletion.
  1. +19 −1 lib/ruote/mon/storage.rb
View
@@ -177,7 +177,25 @@ def get_many(type, key=nil, opts={})
def query_workitems(cr)
opts = {}
- collection('workitems').find(cr)
+ opts[:skip] = cr.delete('offset') || cr.delete('skip')
+ opts[:limit] = cr.delete('limit')
+ opts[:count] = cr.delete('count')
+
+ wfid = cr.delete('wfid')
+
+ count = opts[:count]
+
+ cursor = collection('workitems').find(cr)
+
+ return cursor.count if opts['count']
+
+ cursor.sort(
+ '_id', opts['descending'] ? Mongo::DESCENDING : Mongo::ASCENDING)
+
+ cursor.skip(opts['skip'])
+ cursor.limit(opts['limit'])
+
+ cursor.to_a
end
def ids(type)

0 comments on commit 4fc4422

Please sign in to comment.