80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/rack/oauth2/models/access_token.rb', line 80
def historical(filter = {})
days = filter[:days] || 60
select = { :$gt=> { :created_at=>Time.now - 86400 * days } }
select = {}
if filter[:client_id]
select[:client_id] = BSON::ObjectId(filter[:client_id].to_s)
end
raw = Server::AccessToken.collection.group("function (token) { return { ts: Math.floor(token.created_at / 86400) } }",
select, { :granted=>0 }, "function (token, state) { state.granted++ }")
raw.sort { |a, b| a["ts"] - b["ts"] }
end
|