Added a projection to Clans getMemberSessions to help with the gargantuan fetch running us out of memory.

This commit is contained in:
Nick Winter 2015-04-16 08:03:02 -07:00
parent 7aff510f3e
commit 4de9071f1a
3 changed files with 2 additions and 2 deletions

View file

@ -110,7 +110,6 @@ $gameControlMargin: 30px
@include box-shadow(0px 0px 35px skyblue)
.level-difficulty-banner-text
position: absolute
position: absolute
bottom: 170%
pointer-events: none

View file

@ -35,6 +35,7 @@ module.exports = class ClanDetailsView extends RootView
@clan = new Clan _id: @clanID
@members = new CocoCollection([], { url: "/db/clan/#{@clanID}/members", model: User, comparator:'slug' })
@memberAchievements = new CocoCollection([], { url: "/db/clan/#{@clanID}/member_achievements", model: EarnedAchievement, comparator:'_id' })
# MemberSessions: only loads creatorName, levelName, codeLanguage, submittedCodeLanguage for each session
@memberSessions = new CocoCollection([], { url: "/db/clan/#{@clanID}/member_sessions", model: LevelSession, comparator:'_id' })
@listenTo me, 'sync', => @render?()

View file

@ -116,7 +116,7 @@ ClanHandler = class ClanHandler extends Handler
return @sendDatabaseError(res, err) if err
return @sendDatabaseError(res, err) unless clan
memberIDs = _.map clan.get('members') ? [], (memberID) -> memberID.toHexString()
LevelSession.find {creator: {$in: memberIDs}}, (err, documents) =>
LevelSession.find {creator: {$in: memberIDs}}, 'creatorName levelName codeLanguage submittedCodeLanguage', (err, documents) =>
return @sendDatabaseError(res, err) if err?
cleandocs = (LevelSessionHandler.formatEntity(req, doc) for doc in documents)
@sendSuccess(res, cleandocs)