<commit_before>'use strict';

var memoize            = require('memoizee/plain')
  , validDb            = require('dbjs/valid-dbjs')
  , defineUser         = require('mano-auth/model/user')
  , defineStringLine   = require('dbjs-ext/string/string-line')
  , defineRegistration = require('./../registration');

module.exports = memoize(function (db) {
	var User, StringLine, Registration;
	validDb(db);
	User         = defineUser(db);
	StringLine   = defineStringLine(db);
	Registration = defineRegistration(db);
	User.prototype.defineProperties({
		registrations: {
			type: db.Object,
			nested: true
		},
		applicableRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.registrations.forEach(function (reg) {
					if (reg.isApplicable) {
						regs.push(reg.key);
					}
				}, this);
				return regs;
			}
		},
		mandatoryRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (registration.isMandatory) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		},

		optionalRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (!registration.isMandatory) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		},
		requestedRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (registration.isRequested) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		}
	});

	User.prototype.registrations._descriptorPrototype_.setProperties({
		nested: true,
		type: Registration
	});

	return db.User;
}, { normalizer: require('memoizee/normalizers/get-1')() });<commit_msg>Do not autodefine registration nesteds<commit_after>'use strict';

var memoize            = require('memoizee/plain')
  , validDb            = require('dbjs/valid-dbjs')
  , defineUser         = require('mano-auth/model/user')
  , defineStringLine   = require('dbjs-ext/string/string-line')
  , defineRegistration = require('./../registration');

module.exports = memoize(function (db) {
	var User, StringLine, Registration;
	validDb(db);
	User         = defineUser(db);
	StringLine   = defineStringLine(db);
	Registration = defineRegistration(db);
	User.prototype.defineProperties({
		registrations: {
			type: db.Object,
			nested: true
		},
		applicableRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.registrations.forEach(function (reg) {
					if (reg.isApplicable) {
						regs.push(reg.key);
					}
				}, this);
				return regs;
			}
		},
		mandatoryRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (registration.isMandatory) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		},

		optionalRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (!registration.isMandatory) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		},
		requestedRegistrations: {
			type: StringLine,
			multiple: true,
			value: function () {
				var regs = [];
				this.applicableRegistrations.forEach(function (regName) {
					var registration = this.registrations[regName];
					if (registration.isRequested) {
						regs.push(regName);
					}
				}, this);
				return regs;
			}
		}
	});

	return db.User;
}, { normalizer: require('memoizee/normalizers/get-1')() });
{'fraction_non_alphanumeric': 0.1360078277886497, 'fraction_numerical': 0.0004892367906066536, 'mean_word_length': 2.9853801169590644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4010250', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1307, 'n_words': 237}