add random attribute to user props
Allows easier random sampling
This commit is contained in:
@ -7,7 +7,7 @@ import { saveUser, observeMethod } from '../../server/utils/rx';
|
|||||||
import { blacklistedUsernames } from '../../server/utils/constants';
|
import { blacklistedUsernames } from '../../server/utils/constants';
|
||||||
|
|
||||||
const debug = debugFactory('freecc:user:remote');
|
const debug = debugFactory('freecc:user:remote');
|
||||||
const BROWNIEPOINTS_TIMEOUT = [30, 'seconds'];
|
const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
|
||||||
|
|
||||||
function getAboutProfile({
|
function getAboutProfile({
|
||||||
username,
|
username,
|
||||||
@ -35,6 +35,11 @@ module.exports = function(User) {
|
|||||||
delete User.validations.email;
|
delete User.validations.email;
|
||||||
// set salt factor for passwords
|
// set salt factor for passwords
|
||||||
User.settings.saltWorkFactor = 5;
|
User.settings.saltWorkFactor = 5;
|
||||||
|
// set user.rand to random number
|
||||||
|
User.definition.rawProperties.updated.default =
|
||||||
|
User.definition.properties.updated.default = function() {
|
||||||
|
return Math.random();
|
||||||
|
};
|
||||||
|
|
||||||
// username should not be in blacklist
|
// username should not be in blacklist
|
||||||
User.validatesExclusionOf('username', {
|
User.validatesExclusionOf('username', {
|
||||||
|
@ -152,6 +152,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default": []
|
"default": []
|
||||||
|
},
|
||||||
|
"rand": {
|
||||||
|
"type": "number",
|
||||||
|
"index": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"validations": [],
|
"validations": [],
|
||||||
|
@ -124,6 +124,7 @@ var users = dbObservable
|
|||||||
user[provider + 'id'] = user[provider];
|
user[provider + 'id'] = user[provider];
|
||||||
user[provider] = null;
|
user[provider] = null;
|
||||||
});
|
});
|
||||||
|
user.rand = Math.random();
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user