mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
e56569e5b5
2 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,11 @@ module.exports.connect = () ->
|
|||
mongoose.connect address
|
||||
mongoose.connection.once 'open', -> Grid.gfs = Grid(mongoose.connection.db, mongoose.mongo)
|
||||
|
||||
mongooseCache.install(mongoose, {max: 200, maxAge: 1 * 60 * 1000, debug: false})
|
||||
# Hack around Mongoose not exporting Aggregate so that we can patch its exec, too
|
||||
# https://github.com/LearnBoost/mongoose/issues/1910
|
||||
Level = require '../levels/Level'
|
||||
Aggregate = Level.aggregate().constructor
|
||||
mongooseCache.install(mongoose, {max: 200, maxAge: 1 * 60 * 1000, debug: false}, Aggregate)
|
||||
|
||||
module.exports.generateMongoConnectionString = ->
|
||||
if not testing and config.mongo.mongoose_replica_string
|
||||
|
|
|
@ -160,13 +160,13 @@ LevelHandler = class LevelHandler extends Handler
|
|||
if err then @sendDatabaseError(res, err) else @sendSuccess res, results
|
||||
|
||||
getHistogramData: (req, res, slug) ->
|
||||
query = Session.aggregate [
|
||||
aggregate = Session.aggregate [
|
||||
{$match: {'levelID': slug, 'submitted': true, 'team': req.query.team}}
|
||||
{$project: {totalScore: 1, _id: 0}}
|
||||
]
|
||||
#query.cache() # TODO: implement caching for aggregates
|
||||
aggregate.cache()
|
||||
|
||||
query.exec (err, data) =>
|
||||
aggregate.exec (err, data) =>
|
||||
if err? then return @sendDatabaseError res, err
|
||||
valueArray = _.pluck data, 'totalScore'
|
||||
@sendSuccess res, valueArray
|
||||
|
@ -290,11 +290,11 @@ LevelHandler = class LevelHandler extends Handler
|
|||
sessionQueryParams['team'] = team
|
||||
aggregate = Session.aggregate [
|
||||
{$match: sessionQueryParams}
|
||||
{$project: {'totalScore': 1}}
|
||||
{$sort: {'totalScore': -1}}
|
||||
{$limit: 20}
|
||||
{$project: {'totalScore': 1}}
|
||||
]
|
||||
#aggregate.cache() # TODO: implement caching for aggregates
|
||||
aggregate.cache()
|
||||
aggregate.exec cb
|
||||
|
||||
async.map teams, findTop20Players.bind(@, sessionsQueryParameters), (err, map) =>
|
||||
|
|
Loading…
Reference in a new issue