<commit_before>'use strict'

const _ = require('lodash');

const AtomicCounter = require('./atomic-counter.js');

class GlobalMembershipDescription extends AtomicCounter {
	static description() {
		return {
			"key": "global_membership_description"
		};
	}
	range() {
		if (!this.properties) return [];
		let len = "human-".length;
		let department = this.creation_params && this.creation_params.department || false;

		let chain = _.chain(this.properties.content)

		if (department) chain = chain.filter(item => item.organization == department);

		chain = chain.map('member')
			.map(item => item.slice(len, item.length));

		return chain.value();
	}
	add(params, patchwerk) {
		//@NOTE: never use it without strong need
		//@NOTE: this method is fucking unsafe
		//@TODO: rework this ugly concept
		let id = params.id;
		let role = params.role || 'Operator';
		let organization = params.organization;

		this.properties.content.push({
			"@type": "Membership",
			"@id": "membership-" + this.properties.content.length,
			"member": id,
			"organization": organization,
			"role": role
		});
		this.is_changed = true;
		return patchwerk.save(this)
	}
	inc() {
		throw new Error('not implemented');
	}
}

module.exports = GlobalMembershipDescription;<commit_msg>oper id normalization<commit_after>'use strict'

const _ = require('lodash');

const AtomicCounter = require('./atomic-counter.js');

class GlobalMembershipDescription extends AtomicCounter {
	static description() {
		return {
			"key": "global_membership_description"
		};
	}
	range() {
		if (!this.properties) return [];
		let len = "human-".length;
		let department = this.creation_params && this.creation_params.department || false;

		let chain = _.chain(this.properties.content)

		if (department) chain = chain.filter(item => item.organization == department);

		chain = chain.map('member')
			.map(item => item.slice(len, item.length));

		return chain.value();
	}
	add(params, patchwerk) {
		//@NOTE: never use it without strong need
		//@NOTE: this method is fucking unsafe
		//@TODO: rework this ugly concept
		let id = params.id;
		id = id.indexOf("human-") !== 0 ? "human-" + id : id;

		let role = params.role || 'Operator';
		let organization = params.organization;

		this.properties.content.push({
			"@type": "Membership",
			"@id": "membership-" + this.properties.content.length,
			"member": id,
			"organization": organization,
			"role": role
		});
		this.is_changed = true;
		return patchwerk.save(this)
	}
	inc() {
		throw new Error('not implemented');
	}
}

module.exports = GlobalMembershipDescription;
{'fraction_non_alphanumeric': 0.1501350829795446, 'fraction_numerical': 0.00038595137012736397, 'mean_word_length': 4.042801556420233, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 7, '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': '123975', 'n_tokens_mistral': 904, 'n_tokens_neox': 797, 'n_words': 201}