Merge pull request #2926 from overleaf/bg-create-alpha-compile-group

create alpha compile group

GitOrigin-RevId: edc063ef591a1bed20600a9418e2114f8ab0a3df
This commit is contained in:
Brian Gough 2020-06-19 09:22:22 +01:00 committed by Copybot
parent 2a6f18b6a0
commit 63e8c48c77
3 changed files with 27 additions and 26 deletions

View file

@ -167,26 +167,28 @@ module.exports = CompileManager = {
if (error != null) {
return callback(error)
}
return UserGetter.getUser(project.owner_ref, { features: 1 }, function(
err,
owner
) {
if (error != null) {
return callback(error)
return UserGetter.getUser(
project.owner_ref,
{ alphaProgram: 1, betaProgram: 1, features: 1 },
function(err, owner) {
if (error != null) {
return callback(error)
}
let ownerFeatures = (owner && owner.features) || {}
// put alpha users into their own compile group
if (owner && owner.alphaProgram) {
ownerFeatures.compileGroup = 'alpha'
}
return callback(null, {
timeout:
ownerFeatures.compileTimeout ||
Settings.defaultFeatures.compileTimeout,
compileGroup:
ownerFeatures.compileGroup ||
Settings.defaultFeatures.compileGroup
})
}
return callback(null, {
timeout:
__guard__(
owner != null ? owner.features : undefined,
x => x.compileTimeout
) || Settings.defaultFeatures.compileTimeout,
compileGroup:
__guard__(
owner != null ? owner.features : undefined,
x1 => x1.compileGroup
) || Settings.defaultFeatures.compileGroup
})
})
)
})
},
@ -271,9 +273,3 @@ module.exports = CompileManager = {
})
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -134,6 +134,7 @@ const UserSchema = new Schema({
mendeley: Boolean, // coerce the refProviders values to Booleans
zotero: Boolean
},
alphaProgram: { type: Boolean, default: false }, // experimental features
betaProgram: { type: Boolean, default: false },
overleaf: {
id: { type: Number },

View file

@ -215,7 +215,11 @@ describe('CompileManager', function() {
it("should look up the owner's features", function() {
return this.UserGetter.getUser
.calledWith(this.project.owner_ref, { features: 1 })
.calledWith(this.project.owner_ref, {
alphaProgram: 1,
betaProgram: 1,
features: 1
})
.should.equal(true)
})