Update average playtimes query to match level

This commit is contained in:
Matt Lott 2014-12-31 13:19:46 -08:00
parent 9b6d327c7f
commit 56b4346556
2 changed files with 5 additions and 8 deletions
app/templates/editor/campaign
server/levels

View file

@ -7,7 +7,7 @@
h4 Completion Rates h4 Completion Rates
if levelCompletions if levelCompletions
table.table-bordered.table-condensed.table-hover(style='font-size:10pt') table.table.table-bordered.table-condensed.table-hover(style='font-size:10pt')
thead thead
tr tr
td Date td Date
@ -26,7 +26,7 @@
h4 Average Playtimes h4 Average Playtimes
if levelPlaytimes if levelPlaytimes
table.table-bordered.table-condensed.table-hover(style='font-size:10pt') table.table.table-bordered.table-condensed.table-hover(style='font-size:10pt')
thead thead
tr tr
td Date td Date

View file

@ -370,7 +370,7 @@ LevelHandler = class LevelHandler extends Handler
return @sendSuccess res, levelPlaytimes if levelPlaytimes = @levelPlaytimesCache[cacheKey] return @sendSuccess res, levelPlaytimes if levelPlaytimes = @levelPlaytimesCache[cacheKey]
# Build query # Build query
match = {$match: {$and: [{"state.complete": true}, {"playtime": {$gt: 0}}]}} match = {$match: {$and: [{"state.complete": true}, {"playtime": {$gt: 0}}, {levelID: {$in: levelSlugs}}]}}
match["$match"]["$and"].push created: {$gte: new Date(startDay + "T00:00:00.000Z")} if startDay? match["$match"]["$and"].push created: {$gte: new Date(startDay + "T00:00:00.000Z")} if startDay?
match["$match"]["$and"].push created: {$lt: new Date(endDay + "T00:00:00.000Z")} if endDay? match["$match"]["$and"].push created: {$lt: new Date(endDay + "T00:00:00.000Z")} if endDay?
project = {"$project": {"_id": 0, "levelID": 1, "playtime": 1, "created": {"$concat": [{"$substr": ["$created", 0, 4]}, "-", {"$substr": ["$created", 5, 2]}, "-", {"$substr" : ["$created", 8, 2]}]}}} project = {"$project": {"_id": 0, "levelID": 1, "playtime": 1, "created": {"$concat": [{"$substr": ["$created", 0, 4]}, "-", {"$substr": ["$created", 5, 2]}, "-", {"$substr" : ["$created", 8, 2]}]}}}
@ -383,12 +383,9 @@ LevelHandler = class LevelHandler extends Handler
# Build list of level average playtimes # Build list of level average playtimes
playtimes = [] playtimes = []
for item in data for item in data
created = item._id.created
level = item._id.level
continue unless level? and level in levelSlugs
playtimes.push playtimes.push
level: level level: item._id.level
created: created created: item._id.created
average: item.average average: item.average
@levelPlaytimesCache[cacheKey] = playtimes @levelPlaytimesCache[cacheKey] = playtimes
@sendSuccess res, playtimes @sendSuccess res, playtimes