Skip to content

Commit 15eb221

Browse files
author
Bryan Kendall
committed
rename functions
1 parent 2337966 commit 15eb221

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

lib/models/mongo/instance.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ InstanceSchema.statics.findByBuild = function (build /*, args*/) {
4949
Instance.find.apply(Instance, args);
5050
};
5151

52-
InstanceSchema.methods.getGithubUsername = function (sessionUser, cb) {
52+
InstanceSchema.methods.populateOwnerAndCreatedBy = function (sessionUser, cb) {
5353
var instance = this;
5454
async.parallel({
5555
owner: sessionUser.findGithubUserByGithubId.bind(sessionUser, this.owner.github),
@@ -64,7 +64,8 @@ InstanceSchema.methods.getGithubUsername = function (sessionUser, cb) {
6464
});
6565
};
6666

67-
InstanceSchema.statics.getGithubUsernamesForInstances = function (sessionUser, instances, cb) {
67+
InstanceSchema.statics.populateOwnerAndCreatedByForInstances =
68+
function (sessionUser, instances, cb) {
6869
if (instances.length === 0) {
6970
done();
7071
}

lib/routes/actions/github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function followBranch (instancesKey) {
400400
next();
401401
},
402402
timers.model.stopTimer('github_push_event'),
403-
instances.getGithubUsernamesForInstances(
403+
instances.populateOwnerAndCreatedByForInstances(
404404
'instanceCreator', 'deployedInstances'),
405405
heap.create(),
406406
heap.model.track('githubPushInfo.user.id', 'github_hook_autodeploy', {
@@ -453,4 +453,4 @@ function waitForContextVersionBuildCompleted (contextVersionIdsKey) {
453453
next();
454454
}
455455
);
456-
}
456+
}

lib/routes/instances/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ app.get('/instances/',
269269
ownerIsHelloRunnable('query')
270270
),
271271
instances.find('query'),
272-
timers.model.startTimer('getGithubUsername'),
273-
instances.getGithubUsernamesForInstances('sessionUser', 'instances'),
274-
timers.model.stopTimer('getGithubUsername'),
272+
timers.model.startTimer('populateOwnerAndCreatedByForInstances'),
273+
instances.populateOwnerAndCreatedByForInstances('sessionUser', 'instances'),
274+
timers.model.stopTimer('populateOwnerAndCreatedByForInstances'),
275275
timers.model.startTimer('instance-route.populateModels'),
276276
instances.models.populateModels(),
277277
timers.model.stopTimer('instance-route.populateModels'),
@@ -348,7 +348,7 @@ app.post('/instances/',
348348
error.logIfErrMw),
349349
mw.next('err') // next error
350350
),
351-
instances.model.getGithubUsername('sessionUser'),
351+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
352352
instances.model.populateModels(),
353353
messenger.emitInstanceUpdate('instance', 'post'),
354354
mw.res.send(201, 'instance'));
@@ -362,7 +362,7 @@ app.get('/instances/:id',
362362
me.isOwnerOf('instance'),
363363
instances.model.isPublic(),
364364
me.isModerator),
365-
instances.model.getGithubUsername('sessionUser'),
365+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
366366
instances.model.populateModels(),
367367
mw.res.json('instance'));
368368

@@ -528,7 +528,7 @@ app.patch('/instances/:id',
528528
instances.model.update({ $set: 'body' }),
529529
instances.findById('instanceId')),
530530
instances.findById('instanceId'),
531-
instances.model.getGithubUsername('sessionUser'),
531+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
532532
mw.body({ or: ['name', 'env'] }).require()
533533
.then(
534534
// acquire lock
@@ -695,7 +695,7 @@ app.post('/instances/:id/actions/deploy',
695695
// create container
696696
createSaveAndNetworkContainer,
697697
graph.create(),
698-
instances.model.getGithubUsername('sessionUser'),
698+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
699699
graph.model.graphInstanceDeps('instance'))
700700
.catch(
701701
mw.req().setToErr('err'),
@@ -755,7 +755,7 @@ app.post('/instances/:id/actions/redeploy',
755755
// create container
756756
createSaveAndNetworkContainer,
757757
graph.create(),
758-
instances.model.getGithubUsername('sessionUser'),
758+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
759759
graph.model.graphInstanceDeps('instance'))
760760
.catch(
761761
mw.req().setToErr('err'),
@@ -937,7 +937,7 @@ app.post('/instances/:id/actions/regraph',
937937
checkFound('user', 'Owner not found'),
938938
mw.req().set('ownerUsername', 'user.login'),
939939
graph.create(),
940-
instances.model.getGithubUsername('sessionUser'),
940+
instances.model.populateOwnerAndCreatedBy('sessionUser'),
941941
graph.model.graphInstanceDeps('instance'),
942942
instances.model.populateModels(),
943943
mw.req().set('instance.owner.username', 'ownerUsername'),

0 commit comments

Comments
 (0)