Method: Rack::OAuth2::Server::AccessToken.count
- Defined in:
- lib/rack/oauth2/models/access_token.rb
.count(filter = {}) ⇒ Object
Returns count of access tokens.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rack/oauth2/models/access_token.rb', line 67 def count(filter = {}) select = {} if filter[:days] now = Time.now.to_i range = { :$gt=>now - filter[:days] * 86400, :$lte=>now } select[ filter[:revoked] ? :revoked : :created_at ] = range elsif filter.has_key?(:revoked) select[:revoked] = filter[:revoked] ? { :$ne=>nil } : { :$eq=>nil } end select[:client_id] = BSON::ObjectId(filter[:client_id].to_s) if filter[:client_id] collection.find(select).count end |