mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 02:25:37 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
68c08af508
3 changed files with 79 additions and 12 deletions
|
@ -133,6 +133,7 @@ module.exports = class CampaignEditorView extends RootView
|
|||
@campaign.set('levels', campaignLevels)
|
||||
|
||||
for level in _.values campaignLevels
|
||||
continue if /test/.test @campaign.get('slug') # Don't overwrite level stuff for testing Campaigns
|
||||
model = @levels.findWhere {original: level.original}
|
||||
model.set key, level[key] for key in Campaign.denormalizedLevelProperties
|
||||
@toSave.add model if model.hasLocalChanges()
|
||||
|
@ -201,18 +202,19 @@ module.exports = class CampaignEditorView extends RootView
|
|||
@insertSubView @campaignView
|
||||
|
||||
onTreemaChanged: (e, nodes) =>
|
||||
for node in nodes
|
||||
path = node.getPath()
|
||||
if _.string.startsWith path, '/levels/'
|
||||
parts = path.split('/')
|
||||
original = parts[2]
|
||||
level = @supermodel.getModelByOriginal Level, original
|
||||
campaignLevel = @treema.get "/levels/#{original}"
|
||||
unless /test/.test @campaign.get('slug') # Don't overwrite level stuff for testing Campaigns
|
||||
for node in nodes
|
||||
path = node.getPath()
|
||||
if _.string.startsWith path, '/levels/'
|
||||
parts = path.split('/')
|
||||
original = parts[2]
|
||||
level = @supermodel.getModelByOriginal Level, original
|
||||
campaignLevel = @treema.get "/levels/#{original}"
|
||||
|
||||
@updateRewardsForLevel level, campaignLevel.rewards
|
||||
@updateRewardsForLevel level, campaignLevel.rewards
|
||||
|
||||
level.set key, campaignLevel[key] for key in Campaign.denormalizedLevelProperties
|
||||
@toSave.add level if level.hasLocalChanges()
|
||||
level.set key, campaignLevel[key] for key in Campaign.denormalizedLevelProperties
|
||||
@toSave.add level if level.hasLocalChanges()
|
||||
|
||||
@toSave.add @campaign
|
||||
@campaign.set key, value for key, value of @treema.data
|
||||
|
@ -329,6 +331,7 @@ class LevelNode extends TreemaObjectNode
|
|||
populateData: ->
|
||||
return if @data.name?
|
||||
data = _.pick LevelsNode.levels[@keyForParent].attributes, Campaign.denormalizedLevelProperties
|
||||
console.log 'got the data', data
|
||||
_.extend @data, data
|
||||
|
||||
class CampaignsNode extends TreemaObjectNode
|
||||
|
|
|
@ -184,7 +184,6 @@ module.exports = class CampaignView extends RootView
|
|||
context.levelDifficultyMap = @levelDifficultyMap
|
||||
context.levelPlayCountMap = @levelPlayCountMap
|
||||
context.isIPadApp = application.isIPadApp
|
||||
context.mapType = _.string.slugify @terrain
|
||||
context.requiresSubscription = @requiresSubscription
|
||||
context.editorMode = @editorMode
|
||||
context.adjacentCampaigns = _.filter _.values(_.cloneDeep(@campaign?.get('adjacentCampaigns') or {})), (ac) =>
|
||||
|
@ -378,7 +377,7 @@ module.exports = class CampaignView extends RootView
|
|||
@particleMan.removeEmitters()
|
||||
@particleMan.attach @$el.find('.map')
|
||||
for level in @campaign.renderedLevels ? {}
|
||||
particleKey = ['level', @terrain]
|
||||
particleKey = ['level', @terrain.replace('-branching-test', '')]
|
||||
particleKey.push level.type if level.type and not (level.type in ['hero', 'course'])
|
||||
particleKey.push 'replayable' if level.replayable
|
||||
particleKey.push 'premium' if level.requiresSubscription
|
||||
|
|
65
scripts/mongodb/queries/coursesV1Beta.js
Normal file
65
scripts/mongodb/queries/coursesV1Beta.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Grab course instance data for Courses v1 Beta
|
||||
|
||||
// Usage:
|
||||
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
||||
|
||||
// TODO: order by average levels completed
|
||||
|
||||
function objectIdWithTimestamp(timestamp)
|
||||
{
|
||||
// Convert string date to Date object (otherwise assume timestamp is a date)
|
||||
if (typeof(timestamp) == 'string') timestamp = new Date(timestamp);
|
||||
// Convert date object to hex seconds since Unix epoch
|
||||
var hexSeconds = Math.floor(timestamp/1000).toString(16);
|
||||
// Create an ObjectId with that hex timestamp
|
||||
var constructedObjectId = ObjectId(hexSeconds + "0000000000000000");
|
||||
return constructedObjectId
|
||||
}
|
||||
|
||||
var betaStartDate = new ISODate('2015-10-08');
|
||||
var minMembers = 9;
|
||||
|
||||
var classes = [];
|
||||
var ownerIDs = [];
|
||||
var cursor = db['course.instances'].find({$and: [
|
||||
{_id: {$gte: objectIdWithTimestamp(betaStartDate)}},
|
||||
{$where: 'this.members.length > ' + minMembers}
|
||||
]}).sort({_id: 1});
|
||||
while (cursor.hasNext()) {
|
||||
var doc = cursor.next();
|
||||
var ownerID = doc.ownerID;
|
||||
ownerIDs.push(ownerID);
|
||||
if (!classes[ownerID.valueOf()]) classes[ownerID.valueOf()] = [];
|
||||
classes.push({
|
||||
courseID: doc.courseID,
|
||||
courseInstanceID: doc._id,
|
||||
url: 'codecombat.com/courses/' + doc.courseID.valueOf() + '/' + doc._id.valueOf(),
|
||||
ownerID: doc.ownerID,
|
||||
createDate: ownerID.getTimestamp(),
|
||||
memberCount: doc.members.length,
|
||||
name: doc.name
|
||||
});
|
||||
}
|
||||
|
||||
var userMap = {};
|
||||
cursor = db.users.find({_id: {$in: ownerIDs}});
|
||||
while (cursor.hasNext()) {
|
||||
var doc = cursor.next();
|
||||
if (!userMap[doc._id.valueOf()]) userMap[doc._id.valueOf()] = {};
|
||||
userMap[doc._id.valueOf()].emailLower = doc.emailLower;
|
||||
userMap[doc._id.valueOf()].name = doc.name;
|
||||
}
|
||||
|
||||
for (var i = 0; i < classes.length; i++) {
|
||||
classes[i].email = userMap[classes[i].ownerID.valueOf()].emailLower;
|
||||
}
|
||||
|
||||
classes.sort(function(a, b) {
|
||||
return b.memberCount - a.memberCount;
|
||||
});
|
||||
|
||||
for (var i = 0; i < classes.length; i++) {
|
||||
print(classes[i].url + '\t' + classes[i].memberCount + '\t' + classes[i].email + '\t' + classes[i].name);
|
||||
}
|
||||
|
||||
print(classes.length + ' course instances with over ' + minMembers + ' members');
|
Loading…
Reference in a new issue