|
@@ -4,7 +4,7 @@ var debug = require('debug')('ylt:scoreCalculator');
|
|
|
var ScoreCalculator = function() {
|
|
|
'use strict';
|
|
|
|
|
|
- this.calculate = function(data, profile) {
|
|
|
+ this.calculate = function(data, profile, debugFlag) {
|
|
|
|
|
|
var results = {
|
|
|
categories: {}
|
|
@@ -13,7 +13,9 @@ var ScoreCalculator = function() {
|
|
|
var categoryName;
|
|
|
var weight;
|
|
|
|
|
|
- debug('Starting calculating scores');
|
|
|
+ if (debugFlag) {
|
|
|
+ debug('Starting calculating scores');
|
|
|
+ }
|
|
|
|
|
|
// Calculate categories
|
|
|
for (categoryName in profile.categories) {
|
|
@@ -31,7 +33,7 @@ var ScoreCalculator = function() {
|
|
|
if (data.rules[policyName]) {
|
|
|
policyScore = data.rules[policyName].score + (data.rules[policyName].abnormalityScore * 2);
|
|
|
categoryScore.push(policyScore, weight);
|
|
|
- } else {
|
|
|
+ } else if (debugFlag) {
|
|
|
debug('Warning: could not find rule %s', policyName);
|
|
|
}
|
|
|
|
|
@@ -59,8 +61,10 @@ var ScoreCalculator = function() {
|
|
|
results.globalScore = Math.round(globalScore.getScore());
|
|
|
|
|
|
|
|
|
- debug('Score calculation finished:');
|
|
|
- debug(results);
|
|
|
+ if (debugFlag) {
|
|
|
+ debug('Score calculation finished:');
|
|
|
+ debug(results);
|
|
|
+ }
|
|
|
|
|
|
return results;
|
|
|
};
|