From 8c48e4fc14ce7f152fc9e372cc7e9e1a0769ad45 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 8 Jul 2016 17:04:24 -0700 Subject: [PATCH 01/13] Remove transpiledCode and screenshot from LevelSession --- app/schemas/models/level_session.coffee | 13 +----------- app/styles/admin/level_sessions.sass | 14 ------------- app/templates/admin.jade | 2 -- app/templates/admin/level_sessions.jade | 17 --------------- app/views/admin/LevelSessionsView.coffee | 19 ----------------- app/views/play/level/PlayLevelView.coffee | 25 ----------------------- server/handlers/level_handler.coffee | 2 +- server/models/LevelSession.coffee | 6 +++--- 8 files changed, 5 insertions(+), 93 deletions(-) delete mode 100644 app/styles/admin/level_sessions.sass delete mode 100644 app/templates/admin/level_sessions.jade delete mode 100644 app/views/admin/LevelSessionsView.coffee diff --git a/app/schemas/models/level_session.coffee b/app/schemas/models/level_session.coffee index 339d1f491..95be39816 100644 --- a/app/schemas/models/level_session.coffee +++ b/app/schemas/models/level_session.coffee @@ -54,7 +54,7 @@ _.extend LevelSessionSchema.properties, changed: c.date title: 'Changed' readOnly: true - + dateFirstCompleted: {} # c.stringDate # title: 'Completed' # readOnly: true @@ -62,9 +62,6 @@ _.extend LevelSessionSchema.properties, team: c.shortString() level: LevelSessionLevelSchema - screenshot: - type: 'string' - heroConfig: c.HeroConfigSchema state: c.object {}, @@ -208,14 +205,6 @@ _.extend LevelSessionSchema.properties, submittedCodeLanguage: type: 'string' - transpiledCode: - type: 'object' - additionalProperties: - type: 'object' - additionalProperties: - type: 'string' - format: 'code' - isRanking: type: 'boolean' description: 'Whether this session is still in the first ranking chain after being submitted.' diff --git a/app/styles/admin/level_sessions.sass b/app/styles/admin/level_sessions.sass deleted file mode 100644 index b84a7813e..000000000 --- a/app/styles/admin/level_sessions.sass +++ /dev/null @@ -1,14 +0,0 @@ -#admin-level-sessions-view - .session_tile - display: inline-block - position: relative - margin: 8px - - .session_info - position: absolute - top: 0 - left: 0 - right: 0 - text-align: center - background: rgba(0, 0, 0, 0.5) - color: white diff --git a/app/templates/admin.jade b/app/templates/admin.jade index 4a507a440..cd323fc39 100644 --- a/app/templates/admin.jade +++ b/app/templates/admin.jade @@ -30,8 +30,6 @@ block content h4 Entities ul - li - a(href="/admin/level-sessions") Active Instances li a(href="/admin/trial-requests") Trial Requests li diff --git a/app/templates/admin/level_sessions.jade b/app/templates/admin/level_sessions.jade deleted file mode 100644 index 6d36de660..000000000 --- a/app/templates/admin/level_sessions.jade +++ /dev/null @@ -1,17 +0,0 @@ -extends /templates/base - -block content - - h1 Latest Games - - each session in view.sessions.models - - var url = '/play/level/'+session.get('levelID')+'?session='+session.id - .session_tile - a(href=url) - if session.get('screenshot') - img(src=session.get('screenshot')) - else - img(src="/images/generic-icon.png") - .session_info - .level_name= session.get('levelName') - .creator_name= session.get('creatorName') diff --git a/app/views/admin/LevelSessionsView.coffee b/app/views/admin/LevelSessionsView.coffee deleted file mode 100644 index bd19ac763..000000000 --- a/app/views/admin/LevelSessionsView.coffee +++ /dev/null @@ -1,19 +0,0 @@ -RootView = require 'views/core/RootView' -template = require 'templates/admin/level_sessions' -LevelSession = require 'models/LevelSession' -CocoCollection = require 'collections/CocoCollection' - -class LevelSessionCollection extends CocoCollection - url: '/db/level.session/x/active?project=screenshot,levelName,creatorName' - model: LevelSession - -module.exports = class LevelSessionsView extends RootView - id: 'admin-level-sessions-view' - template: template - - constructor: (options) -> - super options - @getLevelSessions() - - getLevelSessions: -> - @sessions = @supermodel.loadCollection(new LevelSessionCollection(), 'sessions', {cache: false}).model diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index b764b6251..ef48795d7 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -69,7 +69,6 @@ module.exports = class PlayLevelView extends RootView 'god:infinite-loop': 'onInfiniteLoop' 'level:reload-from-data': 'onLevelReloadFromData' 'level:reload-thang-type': 'onLevelReloadThangType' - 'level:session-will-save': 'onSessionWillSave' 'level:started': 'onLevelStarted' 'level:loading-view-unveiling': 'onLoadingViewUnveiling' 'level:loading-view-unveiled': 'onLoadingViewUnveiled' @@ -112,7 +111,6 @@ module.exports = class PlayLevelView extends RootView @gameUIState = new GameUIState() $(window).on 'resize', @onWindowResize - @saveScreenshot = _.throttle @saveScreenshot, 30000 application.tracker?.enableInspectletJS(@levelID) @@ -594,15 +592,6 @@ module.exports = class PlayLevelView extends RootView @bus.removeFirebaseData => @bus.disconnect() - onSessionWillSave: (e) -> - # Something interesting has happened, so (at a lower frequency), we'll save a screenshot. - #@saveScreenshot e.session - - # Throttled - saveScreenshot: (session) => - return unless screenshot = @surface?.screenshot() - session.save {screenshot: screenshot}, {patch: true, type: 'PUT'} - onContactClicked: (e) -> Backbone.Mediator.publish 'level:contact-button-pressed', {} @openModalView contactModal = new ContactModal levelID: @level.get('slug') or @level.id, courseID: @courseID, courseInstanceID: @courseInstanceID @@ -954,20 +943,6 @@ module.exports = class PlayLevelView extends RootView console.error 'Failed to read sessionState in onRealTimeMultiplayerCast' console.info 'Submitting my code' - # Transpiling code copied from scripts/transpile.coffee - # TODO: Should this live somewhere else? - transpiledCode = {} - for thang, spells of @session.get('code') - transpiledCode[thang] = {} - for spellID, spell of spells - spellName = thang + '/' + spellID - continue if @session.get('teamSpells') and not (spellName in @session.get('teamSpells')[@session.get('team')]) - # console.log "PlayLevelView Transpiling spell #{spellName}" - aetherOptions = createAetherOptions functionName: spellID, codeLanguage: @session.get('submittedCodeLanguage'), includeFlow: true - aether = new Aether aetherOptions - transpiledCode[thang][spellID] = aether.transpile spell - # console.log "PlayLevelView transpiled code", transpiledCode - @session.set 'transpiledCode', transpiledCode permissions = @session.get 'permissions' ? [] unless _.find(permissions, (p) -> p.target is 'public' and p.access is 'read') permissions.push target:'public', access:'read' diff --git a/server/handlers/level_handler.coffee b/server/handlers/level_handler.coffee index a44a4e34b..549d49a9c 100644 --- a/server/handlers/level_handler.coffee +++ b/server/handlers/level_handler.coffee @@ -195,7 +195,7 @@ LevelHandler = class LevelHandler extends Handler majorVersion: level.version.major creator: req.user._id+'' - query = Session.find(sessionQuery).select('-screenshot -transpiledCode') + query = Session.find(sessionQuery) # TODO: take out "code" as well, since that can get huge containing the transpiled code for the lat hero, and find another way of having the LadderSubmissionViews in the MyMatchesTab determine ranking readiness query.exec (err, results) => if err then @sendDatabaseError(res, err) else @sendSuccess res, results diff --git a/server/models/LevelSession.coffee b/server/models/LevelSession.coffee index 8edecb749..87ae2320b 100644 --- a/server/models/LevelSession.coffee +++ b/server/models/LevelSession.coffee @@ -84,9 +84,9 @@ LevelSessionSchema.pre 'save', (next) -> LevelSessionSchema.statics.privateProperties = ['code', 'submittedCode', 'unsubscribed'] LevelSessionSchema.statics.editableProperties = ['multiplayer', 'players', 'code', 'codeLanguage', 'completed', 'state', - 'levelName', 'creatorName', 'levelID', 'screenshot', + 'levelName', 'creatorName', 'levelID', 'chat', 'teamSpells', 'submitted', 'submittedCodeLanguage', - 'unsubscribed', 'playtime', 'heroConfig', 'team', 'transpiledCode', + 'unsubscribed', 'playtime', 'heroConfig', 'team', 'browser'] LevelSessionSchema.statics.jsonSchema = jsonschema @@ -94,7 +94,7 @@ LevelSessionSchema.set('toObject', { transform: (doc, ret, options) -> req = options.req return ret unless req # TODO: Make deleting properties the default, but the consequences are far reaching - + submittedCode = doc.get('submittedCode') unless req.user?.isAdmin() or req.user?.id is doc.get('creator') or ('employer' in (req.user?.get('permissions') ? [])) or not doc.get('submittedCode') # TODO: only allow leaderboard access to non-top-5 solutions ret = _.omit ret, LevelSession.privateProperties From ed498ace7e6ab5818252afde88f4e9aaac816c3b Mon Sep 17 00:00:00 2001 From: Matt Sanders Date: Mon, 11 Jul 2016 17:01:33 +1200 Subject: [PATCH 02/13] fixes #3393 by allowing the content to scroll --- app/templates/editor/level/edit.jade | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 5496527d0..e64012f06 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -132,8 +132,9 @@ block outer_content div.tab-pane#editor-level-tasks-tab-view - div.tab-pane#editor-level-patches - .patches-view + div.tab-pane#editor-level-patches.nano + .nano-content + .patches-view div.tab-pane#related-achievements-view From 16c9f100436d3b51b02ae447aeec34d303348678 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Mon, 11 Jul 2016 13:28:48 -0700 Subject: [PATCH 03/13] :bug:Fix course victory dialog level progress counts Use classroom versioned levels instead of latest course levels. Use current level session instead of stale one. --- app/collections/LevelSessions.coffee | 6 ----- .../level/modal/CourseVictoryModal.coffee | 2 ++ .../handlers/course_instance_handler.coffee | 26 +++++++++---------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/collections/LevelSessions.coffee b/app/collections/LevelSessions.coffee index dbbc343a5..20de80e42 100644 --- a/app/collections/LevelSessions.coffee +++ b/app/collections/LevelSessions.coffee @@ -5,12 +5,6 @@ module.exports = class LevelSessionCollection extends CocoCollection url: '/db/level.session' model: LevelSession - fetchMineForCourseInstance: (courseInstanceID, options) -> - options = _.extend({ - url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions" - }, options) - @fetch(options) - fetchForCourseInstance: (courseInstanceID, options) -> options = _.extend({ url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions" diff --git a/app/views/play/level/modal/CourseVictoryModal.coffee b/app/views/play/level/modal/CourseVictoryModal.coffee index 60c68d716..64b7b316f 100644 --- a/app/views/play/level/modal/CourseVictoryModal.coffee +++ b/app/views/play/level/modal/CourseVictoryModal.coffee @@ -131,6 +131,8 @@ module.exports = class CourseVictoryModal extends ModalView for newItem in @newItems.models @views.push(new NewItemView({item: newItem})) + @levelSessions?.remove(@session) + @levelSessions?.add(@session) progressView = new ProgressView({ level: @level nextLevel: @nextLevel diff --git a/server/handlers/course_instance_handler.coffee b/server/handlers/course_instance_handler.coffee index bf26df540..1ee87c11b 100644 --- a/server/handlers/course_instance_handler.coffee +++ b/server/handlers/course_instance_handler.coffee @@ -142,20 +142,20 @@ CourseInstanceHandler = class CourseInstanceHandler extends Handler CourseInstance.findById courseInstanceID, (err, courseInstance) => return @sendDatabaseError(res, err) if err return @sendNotFoundError(res) unless courseInstance - Course.findById courseInstance.get('courseID'), (err, course) => + Classroom.findById courseInstance.get('classroomID'), (err, classroom) => return @sendDatabaseError(res, err) if err - return @sendNotFoundError(res) unless course - Campaign.findById course.get('campaignID'), (err, campaign) => - return @sendDatabaseError(res, err) if err - return @sendNotFoundError(res) unless campaign - levelIDs = (levelID for levelID, level of campaign.get('levels') when not _.contains(level.type, 'ladder')) - query = {$and: [{creator: req.user.id}, {'level.original': {$in: levelIDs}}]} - cursor = LevelSession.find(query) - cursor = cursor.select(req.query.project) if req.query.project - cursor.exec (err, documents) => - return @sendDatabaseError(res, err) if err? - cleandocs = (LevelSessionHandler.formatEntity(req, doc) for doc in documents) - @sendSuccess(res, cleandocs) + return @sendNotFoundError(res) unless classroom + levelIDs = [] + for course in classroom.get('courses') when course._id.equals(courseInstance.get('courseID')) + for level in course.levels when not _.contains(level.type, 'ladder') + levelIDs.push(level.original + "") + query = {$and: [{creator: req.user.id}, {'level.original': {$in: levelIDs}}]} + cursor = LevelSession.find(query) + cursor = cursor.select(req.query.project) if req.query.project + cursor.exec (err, documents) => + return @sendDatabaseError(res, err) if err? + cleandocs = (LevelSessionHandler.formatEntity(req, doc) for doc in documents) + @sendSuccess(res, cleandocs) getMembersAPI: (req, res, courseInstanceID) -> return @sendUnauthorizedError(res) if not req.user? From f8a67ace0eda1e19adeea409a9765fefee369cda Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Mon, 11 Jul 2016 16:01:34 -0700 Subject: [PATCH 04/13] Remove items from course victory dialog --- .../level/modal/CourseVictoryModal.coffee | 78 +------------------ .../modal/CourseVictoryModal.spec.coffee | 55 +++---------- 2 files changed, 10 insertions(+), 123 deletions(-) diff --git a/app/views/play/level/modal/CourseVictoryModal.coffee b/app/views/play/level/modal/CourseVictoryModal.coffee index 64b7b316f..8df142bd1 100644 --- a/app/views/play/level/modal/CourseVictoryModal.coffee +++ b/app/views/play/level/modal/CourseVictoryModal.coffee @@ -1,15 +1,9 @@ ModalView = require 'views/core/ModalView' template = require 'templates/play/level/modal/course-victory-modal' -Achievements = require 'collections/Achievements' Level = require 'models/Level' Course = require 'models/Course' -ThangType = require 'models/ThangType' -ThangTypes = require 'collections/ThangTypes' LevelSessions = require 'collections/LevelSessions' -EarnedAchievement = require 'models/EarnedAchievement' -LocalMongo = require 'lib/LocalMongo' ProgressView = require './ProgressView' -NewItemView = require './NewItemView' Classroom = require 'models/Classroom' utils = require 'core/utils' @@ -18,7 +12,6 @@ module.exports = class CourseVictoryModal extends ModalView template: template closesOnClickOutside: false - initialize: (options) -> @courseID = options.courseID @courseInstanceID = options.courseInstanceID @@ -26,20 +19,10 @@ module.exports = class CourseVictoryModal extends ModalView @session = options.session @level = options.level - @newItems = new ThangTypes() - @newHeroes = new ThangTypes() - + if @courseInstanceID @classroom = new Classroom() @supermodel.trackRequest(@classroom.fetchForCourseInstance(@courseInstanceID)) - @achievements = options.achievements - if not @achievements - @achievements = new Achievements() - @achievements.fetchRelatedToLevel(@session.get('level').original) - @achievements = @supermodel.loadCollection(@achievements, 'achievements').model - @listenToOnce @achievements, 'sync', @onAchievementsLoaded - else - @onAchievementsLoaded() @playSound 'victory' @nextLevel = new Level() @@ -68,69 +51,10 @@ module.exports = class CourseVictoryModal extends ModalView return super(arguments...) - - onAchievementsLoaded: -> - @achievements.models = _.filter @achievements.models, (m) -> not m.get('query')?.ladderAchievementDifficulty # Don't show higher AI difficulty achievements - itemOriginals = [] - heroOriginals = [] - achievementIDs = [] - for achievement in @achievements.models - rewards = achievement.get('rewards') or {} - heroOriginals.push rewards.heroes or [] - itemOriginals.push rewards.items or [] - achievement.completed = LocalMongo.matchesQuery(@session.attributes, achievement.get('query')) - achievementIDs.push(achievement.id) if achievement.completed - - itemOriginals = _.uniq _.flatten itemOriginals - heroOriginals = _.uniq _.flatten heroOriginals - #project = ['original', 'rasterIcon', 'name', 'soundTriggers', 'i18n'] # This is what we need, but the PlayHeroesModal needs more, and so we load more to fill up the supermodel. - project = ['original', 'rasterIcon', 'name', 'slug', 'soundTriggers', 'featureImages', 'gems', 'heroClass', 'description', 'components', 'extendedName', 'unlockLevelName', 'i18n'] - for [newThangTypeCollection, originals] in [[@newItems, itemOriginals], [@newHeroes, heroOriginals]] - for original in originals - thang= new ThangType() - thang.url = "/db/thang.type/#{original}/version" - thang.project = project - @supermodel.loadModel(thang) - newThangTypeCollection.add(thang) - - @newEarnedAchievements = [] - for achievement in @achievements.models - continue unless achievement.completed - ea = new EarnedAchievement({ - collection: achievement.get('collection') - triggeredBy: @session.id - achievement: achievement.id - }) - if me.isSessionless() - @newEarnedAchievements.push ea - else - ea.save() - # Can't just add models to supermodel because each ea has the same url - ea.sr = @supermodel.addSomethingResource(ea.cid) - @newEarnedAchievements.push ea - @listenToOnce ea, 'sync', (model) -> - model.sr.markLoaded() - if _.all((ea.id for ea in @newEarnedAchievements)) - unless me.loading - @supermodel.loadModel(me, {cache: false}) - @newEarnedAchievementsResource.markLoaded() - - unless me.isSessionless() - # have to use a something resource because addModelResource doesn't handle models being upserted/fetched via POST like we're doing here - @newEarnedAchievementsResource = @supermodel.addSomethingResource('earned achievements') if @newEarnedAchievements.length - - onLoaded: -> super() @views = [] - # TODO: Add main victory view - # TODO: Add level up view - # TODO: Add new hero view? - - for newItem in @newItems.models - @views.push(new NewItemView({item: newItem})) - @levelSessions?.remove(@session) @levelSessions?.add(@session) progressView = new ProgressView({ diff --git a/test/app/views/play/level/modal/CourseVictoryModal.spec.coffee b/test/app/views/play/level/modal/CourseVictoryModal.spec.coffee index 3ca11cad2..21a5f3ff7 100644 --- a/test/app/views/play/level/modal/CourseVictoryModal.spec.coffee +++ b/test/app/views/play/level/modal/CourseVictoryModal.spec.coffee @@ -1,9 +1,7 @@ Course = require 'models/Course' Level = require 'models/Level' LevelSession = require 'models/LevelSession' -Achievements = require 'collections/Achievements' CourseVictoryModal = require 'views/play/level/modal/CourseVictoryModal' -NewItemView = require 'views/play/level/modal/NewItemView' ProgressView = require 'views/play/level/modal/ProgressView' factories = require 'test/app/factories' @@ -12,7 +10,7 @@ describe 'CourseVictoryModal', -> me.clear() it 'will eventually be the only victory modal' - + makeViewOptions = -> level = factories.makeLevel() course = factories.makeCourse() @@ -21,24 +19,18 @@ describe 'CourseVictoryModal', -> course: factories.makeCourse() level: level session: factories.makeLevelSession({ state: { complete: true } }, { level }) - achievements: new Achievements([factories.makeLevelCompleteAchievement({}, {level: level})]) nextLevel: factories.makeLevel() courseInstanceID: courseInstance.id courseID: course.id } nextLevelRequest = null - + handleRequests = (modal) -> requests = jasmine.Ajax.requests.all() - thangRequest = _.find(requests, (r) -> _.string.startsWith(r.url, '/db/thang.type')) - thangRequest?.respondWith({status: 200, responseText: factories.makeThangType().stringify()}) - modal.newEarnedAchievements[0].fakeRequests[0].respondWith({ - status: 200, responseText: factories.makeEarnedAchievement().stringify() - }) modal.levelSessions.fakeRequests[0].respondWith({ status: 200, responseText: '[]' }) modal.classroom.fakeRequests[0].respondWith({ - status: 200, responseText: factories.makeClassroom().stringify() + status: 200, responseText: factories.makeClassroom().stringify() }) if me.fakeRequests lastRequest = _.last(me.fakeRequests) @@ -47,7 +39,7 @@ describe 'CourseVictoryModal', -> status: 200, responseText: factories.makeUser().stringify() }) nextLevelRequest = modal.nextLevel.fakeRequests[0] - + describe 'given a course level with a next level and no item or hero rewards', -> modal = null @@ -63,7 +55,7 @@ describe 'CourseVictoryModal', -> expect(modal.views[0] instanceof ProgressView).toBe(true) it '(demo)', -> jasmine.demoModal(modal) - + describe 'its ProgressView', -> it 'has a next level button which navigates to the next level on click', -> spyOn(application.router, 'navigate') @@ -71,12 +63,12 @@ describe 'CourseVictoryModal', -> expect(button.length).toBe(1) button.click() expect(application.router.navigate).toHaveBeenCalled() - + it 'has two columns', -> expect(modal.$('.row:first .col-sm-12').length).toBe(0) expect(modal.$('.row:first .col-sm-5').length).toBe(1) expect(modal.$('.row:first .col-sm-7').length).toBe(1) - + describe 'given a course level without a next level', -> modal = null @@ -91,13 +83,13 @@ describe 'CourseVictoryModal', -> handleRequests(modal) nextLevelRequest.respondWith({status: 404, responseText: '{}'}) _.defer done - + describe 'its ProgressView', -> it 'has a single large column, since there is no next level to display', -> expect(modal.$('.row:first .col-sm-12').length).toBe(1) expect(modal.$('.row:first .col-sm-5').length).toBe(0) expect(modal.$('.row:first .col-sm-7').length).toBe(0) - + it 'has a done button which navigates to the CourseDetailsView for the given course instance', -> spyOn(application.router, 'navigate') button = modal.$el.find('#done-btn') @@ -106,32 +98,3 @@ describe 'CourseVictoryModal', -> expect(application.router.navigate).toHaveBeenCalled() it '(demo)', -> jasmine.demoModal(modal) - - - describe 'given a course level with a new item', -> - modal = null - - beforeEach (done) -> - options = makeViewOptions() - - # insert new item into achievement properties - achievement = options.achievements.first() - rewards = _.cloneDeep(achievement.get('rewards')) - rewards.items = ["53e4108204c00d4607a89f78"] - achievement.set('rewards', rewards) - - modal = new CourseVictoryModal(options) - handleRequests(modal) - nextLevelRequest.respondWith({status: 200, responseText: factories.makeLevel().stringify()}) - _.defer done - - it 'includes a NewItemView when the level rewards a new item', -> - expect(_.size(modal.views)).toBe(2) - expect(modal.views[0] instanceof NewItemView).toBe(true) - - it 'continues to the ProgressView when you click the continue button', -> - expect(modal.currentView instanceof NewItemView).toBe(true) - modal.$el.find('#continue-btn').click() - expect(modal.currentView instanceof ProgressView).toBe(true) - - it '(demo)', -> jasmine.demoModal(modal) From 88bd74a5a5477831281ec272cb2814453eadc0e0 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 11 Jul 2016 16:40:05 -0700 Subject: [PATCH 05/13] Add options for separate level session database and aux level session database. --- server/models/AnalyticsLogEvent.coffee | 2 +- server/models/LevelSession.coffee | 33 +++++++++++++++++++++++++- server_config.coffee | 9 +++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/server/models/AnalyticsLogEvent.coffee b/server/models/AnalyticsLogEvent.coffee index 02b9e9858..e824ad776 100644 --- a/server/models/AnalyticsLogEvent.coffee +++ b/server/models/AnalyticsLogEvent.coffee @@ -31,6 +31,6 @@ AnalyticsLogEventSchema.statics.logEvent = (user, event, properties={}) -> unless config.proxy analyticsMongoose = mongoose.createConnection() analyticsMongoose.open "mongodb://#{config.mongo.analytics_host}:#{config.mongo.analytics_port}/#{config.mongo.analytics_db}", (error) -> - log.warn "Couldnt connect to analytics", error + log.error "Couldnt connect to analytics", error if error module.exports = AnalyticsLogEvent = analyticsMongoose.model('analytics.log.event', AnalyticsLogEventSchema, config.mongo.analytics_collection) diff --git a/server/models/LevelSession.coffee b/server/models/LevelSession.coffee index 8edecb749..a46512f43 100644 --- a/server/models/LevelSession.coffee +++ b/server/models/LevelSession.coffee @@ -106,4 +106,35 @@ LevelSessionSchema.set('toObject', { return ret }) -module.exports = LevelSession = mongoose.model('level.session', LevelSessionSchema, 'level.sessions') +if config.mongo.level_session_host? + levelSessionMongo = mongoose.createConnection() + levelSessionMongo.open "mongodb://#{config.mongo.level_session_host}:#{config.mongo.level_session_port}/#{config.mongo.level_session_db}", (error) -> + if error + log.error "Couldnt connect to session mongo!", error + else + log.info "Connected to seperate level session server." +else + levelSessionMongo = mongoose + +LevelSession = levelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions') + +if config.mongo.level_session_aux_host? + auxLevelSessionMongo = mongoose.createConnection() + auxLevelSessionMongo.open "mongodb://#{config.mongo.level_session_aux_host}:#{config.mongo.level_session_aux_port}/#{config.mongo.level_session_aux_db}", (error) -> + if error + log.error "Couldnt connect to AUX session mongo!", error + else + log.info "Connected to seperate level AUX session server." + + auxLevelSession = auxLevelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions') + + LevelSessionSchema.post 'save', (d) -> + return unless d instanceof LevelSession + console.log "Saving D", arguments + o = d.toObject {transform: ((x, r) -> r), virtuals: false} + console.log "Guess I should write", o + auxLevelSession.collection.save o, {w:1}, (err, v) -> + console.log err.stack if err + console.log("update sent", arguments) + +module.exports = LevelSession diff --git a/server_config.coffee b/server_config.coffee index d76451789..e58fa3efb 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -26,6 +26,15 @@ config.mongo = mongoose_tokyo_replica_string: process.env.COCO_MONGO_MONGOOSE_TOKYO_REPLICA_STRING or '' mongoose_saoPaulo_replica_string : process.env.COCO_MONGO_MONGOOSE_SAOPAULO_REPLICA_STRING or '' +if process.env.COCO_MONGO_LS_HOST? or process.env.COCO_MONGO_LS_DATABASE_NAME? + config.mongo.level_session_host = process.env.COCO_MONGO_LS_HOST or process.env.COCO_MONGO_HOST or 'localhost' + config.mongo.level_session_port = process.env.COCO_MONGO_LS_PORT or process.env.COCO_MONGO_PORT or 27017 + config.mongo.level_session_db = process.env.COCO_MONGO_LS_DATABASE_NAME or process.env.COCO_MONGO_DATABASE_NAME or 'coco' + +if process.env.COCO_MONGO_LS_AUX_HOST? and process.env.COCO_MONGO_LS_AUX_PORT? and process.env.COCO_MONGO_LS_AUX_DATABASE_NAME + config.mongo.level_session_aux_host = process.env.COCO_MONGO_LS_AUX_HOST or process.env.COCO_MONGO_HOST or 'localhost' + config.mongo.level_session_aux_port = process.env.COCO_MONGO_LS_AUX_PORT or process.env.COCO_MONGO_PORT or 27017 + config.mongo.level_session_aux_db = process.env.COCO_MONGO_LS_AUX_DATABASE_NAME or 'coco_aux' if config.tokyo or config.saoPaulo From cd47a9d4ea71f5477b087693479522a0caedc284 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 11 Jul 2016 16:59:00 -0700 Subject: [PATCH 06/13] Fix inconsistent verifier results when run with multiple levels batched --- app/views/editor/verifier/VerifierTest.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/editor/verifier/VerifierTest.coffee b/app/views/editor/verifier/VerifierTest.coffee index 7c84e7389..4fad8d0e3 100644 --- a/app/views/editor/verifier/VerifierTest.coffee +++ b/app/views/editor/verifier/VerifierTest.coffee @@ -25,9 +25,9 @@ module.exports = class VerifierTest extends CocoClass @loadStartTime = new Date() @god = new God maxAngels: 1, headless: true @levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, headless: true, fakeSessionConfig: {codeLanguage: @language, callback: @configureSession} - @listenToOnce @levelLoader, 'world-necessities-loaded', @onWorldNecessitiesLoaded + @listenToOnce @levelLoader, 'world-necessities-loaded', -> _.defer @onWorldNecessitiesLoaded - onWorldNecessitiesLoaded: -> + onWorldNecessitiesLoaded: => # Called when we have enough to build the world, but not everything is loaded @grabLevelLoaderData() @@ -134,8 +134,10 @@ module.exports = class VerifierTest extends CocoClass setTimeout @cleanup, 100 cleanup: => + if @levelLoader + @stopListening @levelLoader + @levelLoader.destroy() if @god @stopListening @god @god.destroy() - @world = null From b2bdae274f57a81f7078d2635b57e9976a516b53 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 11 Jul 2016 18:02:58 -0700 Subject: [PATCH 07/13] Lets just use replica strings for level session connections. --- server/models/LevelSession.coffee | 17 +++++++---------- server_config.coffee | 12 ++++-------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/server/models/LevelSession.coffee b/server/models/LevelSession.coffee index a46512f43..9fdedab2b 100644 --- a/server/models/LevelSession.coffee +++ b/server/models/LevelSession.coffee @@ -106,35 +106,32 @@ LevelSessionSchema.set('toObject', { return ret }) -if config.mongo.level_session_host? +if config.mongo.level_session_replica_string? levelSessionMongo = mongoose.createConnection() - levelSessionMongo.open "mongodb://#{config.mongo.level_session_host}:#{config.mongo.level_session_port}/#{config.mongo.level_session_db}", (error) -> + levelSessionMongo.open config.mongo.level_session_replica_string, (error) -> if error log.error "Couldnt connect to session mongo!", error else - log.info "Connected to seperate level session server." + log.info "Connected to seperate level session server with string", config.mongo.level_session_replica_string else levelSessionMongo = mongoose LevelSession = levelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions') -if config.mongo.level_session_aux_host? +if config.mongo.level_session_aux_replica_string? auxLevelSessionMongo = mongoose.createConnection() - auxLevelSessionMongo.open "mongodb://#{config.mongo.level_session_aux_host}:#{config.mongo.level_session_aux_port}/#{config.mongo.level_session_aux_db}", (error) -> + auxLevelSessionMongo.open config.mongo.level_session_aux_replica_string, (error) -> if error log.error "Couldnt connect to AUX session mongo!", error else - log.info "Connected to seperate level AUX session server." + log.info "Connected to seperate level AUX session server with string", config.mongo.level_session_aux_replica_string auxLevelSession = auxLevelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions') LevelSessionSchema.post 'save', (d) -> return unless d instanceof LevelSession - console.log "Saving D", arguments o = d.toObject {transform: ((x, r) -> r), virtuals: false} - console.log "Guess I should write", o auxLevelSession.collection.save o, {w:1}, (err, v) -> - console.log err.stack if err - console.log("update sent", arguments) + log.error err.stack if err module.exports = LevelSession diff --git a/server_config.coffee b/server_config.coffee index e58fa3efb..b18aa8a18 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -26,15 +26,11 @@ config.mongo = mongoose_tokyo_replica_string: process.env.COCO_MONGO_MONGOOSE_TOKYO_REPLICA_STRING or '' mongoose_saoPaulo_replica_string : process.env.COCO_MONGO_MONGOOSE_SAOPAULO_REPLICA_STRING or '' -if process.env.COCO_MONGO_LS_HOST? or process.env.COCO_MONGO_LS_DATABASE_NAME? - config.mongo.level_session_host = process.env.COCO_MONGO_LS_HOST or process.env.COCO_MONGO_HOST or 'localhost' - config.mongo.level_session_port = process.env.COCO_MONGO_LS_PORT or process.env.COCO_MONGO_PORT or 27017 - config.mongo.level_session_db = process.env.COCO_MONGO_LS_DATABASE_NAME or process.env.COCO_MONGO_DATABASE_NAME or 'coco' +if process.env.COCO_MONGO_LS_REPLICA_STRING? + config.mongo.level_session_replica_string = process.env.COCO_MONGO_LS_REPLICA_STRING -if process.env.COCO_MONGO_LS_AUX_HOST? and process.env.COCO_MONGO_LS_AUX_PORT? and process.env.COCO_MONGO_LS_AUX_DATABASE_NAME - config.mongo.level_session_aux_host = process.env.COCO_MONGO_LS_AUX_HOST or process.env.COCO_MONGO_HOST or 'localhost' - config.mongo.level_session_aux_port = process.env.COCO_MONGO_LS_AUX_PORT or process.env.COCO_MONGO_PORT or 27017 - config.mongo.level_session_aux_db = process.env.COCO_MONGO_LS_AUX_DATABASE_NAME or 'coco_aux' +if process.env.COCO_MONGO_LS_AUX_REPLICA_STRING? + config.mongo.level_session_aux_replica_string = process.env.COCO_MONGO_LS_AUX_REPLICA_STRING if config.tokyo or config.saoPaulo From 102139ce8fbc40a996c436381b78ca83f9d38144 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Tue, 12 Jul 2016 06:32:50 -0700 Subject: [PATCH 08/13] Update automatic sales lead importing Shifting distributions around a bit. --- scripts/followupCloseIoLeads.js | 6 +++--- scripts/updateCloseIoLeads.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/followupCloseIoLeads.js b/scripts/followupCloseIoLeads.js index bc8096dc0..31008e286 100644 --- a/scripts/followupCloseIoLeads.js +++ b/scripts/followupCloseIoLeads.js @@ -1,7 +1,7 @@ // Follow up on Close.io leads 'use strict'; -if (process.argv.length !== 7) { +if (process.argv.length !== 8) { log("Usage: node