Update campaign editor analytics

Level view recent sessions is latest - 10 minutes.
This commit is contained in:
Matt Lott 2015-01-08 17:00:02 -08:00
parent 583cb03b89
commit 372ac20a67
2 changed files with 5 additions and 3 deletions

View file

@ -58,8 +58,7 @@ class AnalyticsLogEventHandler extends Handler
# Build query
queryParams = {$and: [
{$or: [{"event" : 'Started Level'}, {"event" : 'Saw Victory'}]}#,
# {$or: [{"properties.level": "Endangered Burl"}, {"properties.levelID": "endangered-burl"}, {"properties.level": "Dungeons of Kithgard"}, {"properties.levelID": "dungeons-of-kithgard"}]}
{$or: [{"event" : 'Started Level'}, {"event" : 'Saw Victory'}]}
]}
queryParams["$and"].push created: {$gte: new Date(startDay + "T00:00:00.000Z")} if startDay?
queryParams["$and"].push created: {$lt: new Date(endDay + "T00:00:00.000Z")} if endDay?

View file

@ -38,7 +38,10 @@ class LevelSessionHandler extends Handler
return @sendSuccess res, [] unless levelSlug?
query = @modelClass.find({"levelID": levelSlug}).sort({changed: -1}).limit(limit)
today = new Date()
today.setUTCMinutes(today.getUTCMinutes() - 10)
queryParams = {$and: [{"changed": {"$lt": today}}, {"levelID": levelSlug}]}
query = @modelClass.find(queryParams).sort({changed: -1}).limit(limit)
query.exec (err, documents) =>
return @sendDatabaseError(res, err) if err
@sendSuccess res, documents