<commit_before>'use strict';

var processingStepsMeta = require('../processing-steps-meta');

module.exports = {
	'/': {
		decorateContext: function () {
			this.processingStepsMeta = processingStepsMeta;
		},
		view: require('../view/statistics-dashboard')
	},
	files: require('../view/statistics-files-completed'),
	'files/pending': {
		decorateContext: function () {
			this.processingStepsMeta = processingStepsMeta;
		},
		view: require('../view/statistics-files-pending')
	},
	'files/accounts': require('../view/statistics-files-accounts'),
	time: {
		decorateContext: function () {
			this.processingStepsMeta = processingStepsMeta;
		},
		view: require('../view/statistics-time-per-role')
	},
	'time/per-person': {
		decorateContext: function () {
			this.processingStepsMeta = processingStepsMeta;
		},
		view: require('../view/statistics-time-per-person')
	},
	flow: {
		decorateContext: function () {
			this.processingStepsMeta = processingStepsMeta;
		},
		view: require('../view/statistics-flow-certificates')
	},
	'flow/by-role': {
		view: require('../view/statistics-flow-roles')
	},
	'flow/by-operator': {
		view: require('../view/statistics-flow-operators')
	},
	'flow/rejections': {
		view: require('../view/statistics-flow-rejections')
	},

	profile: require('../view/user-profile')
};<commit_msg>Issue #1796. Add business process views routes<commit_after>'use strict';

var hyphenToCamel        = require('es5-ext/string/#/hyphen-to-camel')
  , matchBusinessProcess = require('./utils/inspector-match-business-process')
  , findFirstUploadKey   = require('./utils/inspector-find-first-upload-key')
  , matchUpload          = require('./utils/inspector-match-upload')
  , matchCertificate     = require('./utils/user-match-certificate')
  , processingStepsMeta  = require('../processing-steps-meta');

module.exports = function () {
	var match = matchBusinessProcess();

	return {
		// Pages with statistics information
		'/': {
			decorateContext: function () {
				this.processingStepsMeta = processingStepsMeta;
			},
			view: require('../view/statistics-dashboard')
		},
		files: require('../view/statistics-files-completed'),
		'files/pending': {
			decorateContext: function () {
				this.processingStepsMeta = processingStepsMeta;
			},
			view: require('../view/statistics-files-pending')
		},
		'files/accounts': require('../view/statistics-files-accounts'),
		time: {
			decorateContext: function () {
				this.processingStepsMeta = processingStepsMeta;
			},
			view: require('../view/statistics-time-per-role')
		},
		'time/per-person': {
			decorateContext: function () {
				this.processingStepsMeta = processingStepsMeta;
			},
			view: require('../view/statistics-time-per-person')
		},
		flow: {
			decorateContext: function () {
				this.processingStepsMeta = processingStepsMeta;
			},
			view: require('../view/statistics-flow-certificates')
		},
		'flow/by-role': {
			view: require('../view/statistics-flow-roles')
		},
		'flow/by-operator': {
			view: require('../view/statistics-flow-operators')
		},
		'flow/rejections': {
			view: require('../view/statistics-flow-rejections')
		},

		// Business process views

		'[0-9][a-z0-9]*': {
			match: function (businessProcessId) {
				return match.call(this, businessProcessId).then(function (result) {
					if (!result) return false;
					var firstUniqueKey = findFirstUploadKey.call(this, 'requirementUpload');
					if (firstUniqueKey) {
						return matchUpload.call(this, 'requirementUpload', firstUniqueKey);
					}
					return true;
				}.bind(this));
			},
			view: require('../view/business-process-official-document')
		},
		'[0-9][a-z0-9]*/documents/[a-z][a-z0-9-]*': {
			match: function (businessProcessId, uniqueKey) {
				return match.call(this, businessProcessId).then(function (result) {
					if (!result) return false;
					var firstUniqueKey = findFirstUploadKey.call(this, 'requirementUpload');
					if (!firstUniqueKey) return false;
					uniqueKey = hyphenToCamel.call(uniqueKey);
					if (firstUniqueKey === uniqueKey) return false;
					return matchUpload.call(this, 'requirementUpload', uniqueKey);
				}.bind(this));
			},
			view: require('../view/business-process-official-document')
		},
		'[0-9][a-z0-9]*/payment-receipts/[a-z][a-z0-9-]*': {
			match: function (businessProcessId, uniqueKey) {
				return match.call(this, businessProcessId).then(function (result) {
					if (!result) return false;
					return matchUpload.call(this, 'paymentReceiptUpload', hyphenToCamel.call(uniqueKey));
				}.bind(this));
			},
			view: require('../view/business-process-official-payment')
		},
		'[0-9][a-z0-9]*/certificates/[a-z][a-z0-9-]*': {
			match: function (businessProcessId, uniqueKey) {
				return match.call(this, businessProcessId).then(function (result) {
					if (!result) return false;
					return matchCertificate.call(this, hyphenToCamel.call(uniqueKey), {
						collection: 'applicable'
					});
				}.bind(this));
			},
			view: require('../view/business-process-official-certificate')
		},
		'[0-9][a-z0-9]*/data': {
			match: match,
			decorateContext: function () {
				this.dataSnapshot = this.businessProcess.dataForms.dataSnapshot.resolved;
			},
			view: require('../view/business-process-official-data')
		},

		// Other

		profile: require('../view/user-profile')
	};
};
{'fraction_non_alphanumeric': 0.17511781338360038, 'fraction_numerical': 0.005843543826578699, 'mean_word_length': 3.741733690795353, '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': '3177790', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1710, 'n_words': 251}