mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 16:30:11 +00:00
Add overlap analysis.
This commit is contained in:
parent
f2bf09bf96
commit
08ab512f4c
@ -59,23 +59,55 @@ Employment gap analysis for HackMyResume.
|
|||||||
// increment a reference count. Each time an end date is found, decrement
|
// increment a reference count. Each time an end date is found, decrement
|
||||||
// the reference count. When the reference count reaches 0, we have a gap.
|
// the reference count. When the reference count reaches 0, we have a gap.
|
||||||
// When the reference count is > 0, the candidate is employed.
|
// When the reference count is > 0, the candidate is employed.
|
||||||
var num_gaps = 0, ref_count = 0, gap_start,gaps = [];
|
var num_gaps = 0, ref_count = 0, gap_start, total_days = 0, total_work_days = 0,
|
||||||
|
coverage = { gaps: [], overlaps: [] };
|
||||||
new_e.forEach( function(point) {
|
new_e.forEach( function(point) {
|
||||||
var inc = point[0] === 'start' ? 1 : -1;
|
var inc = point[0] === 'start' ? 1 : -1;
|
||||||
ref_count += inc;
|
ref_count += inc;
|
||||||
if( ref_count === 0 ) {
|
if( ref_count === 0 ) {
|
||||||
gaps.push( { start: point[1], end: null });
|
coverage.gaps.push( { start: point[1], end: null });
|
||||||
}
|
}
|
||||||
else if( ref_count === 1 && inc === 1 ) {
|
else if( ref_count === 1 && inc === 1 ) {
|
||||||
var lastGap = _.last( gaps );
|
var lastGap = _.last( coverage.gaps );
|
||||||
if( lastGap ) {
|
if( lastGap ) {
|
||||||
lastGap.end = point[1];
|
lastGap.end = point[1];
|
||||||
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
||||||
|
total_days += lastGap.duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( ref_count === 2 && inc === 1 ) {
|
||||||
|
coverage.overlaps.push( { start: point[1], end: null });
|
||||||
|
}
|
||||||
|
else if( ref_count === 1 && inc === -1 ) {
|
||||||
|
var lastOverlap = _.last( coverage.overlaps );
|
||||||
|
if( lastOverlap ) {
|
||||||
|
lastOverlap.end = point[1];
|
||||||
|
lastOverlap.duration = lastOverlap.end.diff( lastOverlap.start, 'days' );
|
||||||
|
if( lastOverlap.duration === 0 ) {
|
||||||
|
coverage.overlaps.pop();
|
||||||
|
}
|
||||||
|
total_work_days += lastOverlap.duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return gaps;
|
// var now = moment();
|
||||||
|
// _.each( coverage.overlaps, function(ol) {
|
||||||
|
// return ol.end = ol.end || now;
|
||||||
|
// });
|
||||||
|
if( !_.last( coverage.overlaps ).end ) {
|
||||||
|
var l = _.last( coverage.overlaps );
|
||||||
|
l.end = moment();
|
||||||
|
l.duration = l.end.diff( l.start, 'days' );
|
||||||
|
}
|
||||||
|
|
||||||
|
coverage.duration = total_days;
|
||||||
|
coverage.pct = ( total_days > 0 ) ?
|
||||||
|
(100.0 - ( total_days / rez.duration('days') * 100)).toFixed(1) + '%' :
|
||||||
|
'???';
|
||||||
|
|
||||||
|
|
||||||
|
return coverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,32 +55,37 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
return val.run( resumeObject.rez );
|
return val.run( resumeObject.rez );
|
||||||
});
|
});
|
||||||
|
|
||||||
log(chalk.cyan('\nSECTIONS (') + chalk.cyan.bold(_.keys(info.totals).length) + chalk.cyan('):\n'));
|
log(chalk.cyan.bold('\nSECTIONS') + chalk.cyan(' (') + chalk.white.bold(_.keys(info.totals).length) + chalk.cyan('):\n'));
|
||||||
var pad = require('string-padding');
|
var pad = require('string-padding');
|
||||||
_.each( info.totals, function(tot, key) {
|
_.each( info.totals, function(tot, key) {
|
||||||
log(chalk.cyan(pad(key + ': ',20)) + chalk.cyan.bold(pad(tot.toString(),4)));
|
log(chalk.cyan(pad(key + ': ',20)) + chalk.cyan.bold(pad(tot.toString(),4)));
|
||||||
});
|
});
|
||||||
|
|
||||||
log();
|
log();
|
||||||
log(chalk.cyan('GAPS (') + chalk.cyan.bold(info.gaps.length) + chalk.cyan('):\n'));
|
log(chalk.cyan.bold('COVERAGE') + chalk.cyan(' (') + chalk.white.bold( info.coverage.pct ) + chalk.cyan('):\n'));
|
||||||
log(chalk.cyan(pad('Lengths: ', padding + 3)) + info.gaps.map(function(g) {
|
log(chalk.cyan(pad('Gaps: ', padding + 3)) + chalk.cyan.bold(info.coverage.gaps.length) + chalk.cyan(' [') + info.coverage.gaps.map(function(g) {
|
||||||
var clr = 'green';
|
var clr = 'green';
|
||||||
if( g.duration > 35 ) clr = 'yellow';
|
if( g.duration > 35 ) clr = 'yellow';
|
||||||
if( g.duration > 90 ) clr = 'red';
|
if( g.duration > 90 ) clr = 'red';
|
||||||
return chalk[clr].bold( g.duration) ;
|
return chalk[clr].bold( g.duration) ;
|
||||||
}).join(', ') );
|
}).join(', ') + chalk.cyan(']') );
|
||||||
|
log(chalk.cyan(pad('Overlaps: ', padding + 3)) + chalk.cyan.bold(info.coverage.overlaps.length) + chalk.cyan(' [') + info.coverage.overlaps.map(function(ol) {
|
||||||
|
var clr = 'green';
|
||||||
|
if( ol.duration > 35 ) clr = 'yellow';
|
||||||
|
if( ol.duration > 90 ) clr = 'red';
|
||||||
|
return chalk[clr].bold( ol.duration) ;
|
||||||
|
}).join(', ') + chalk.cyan(']') );
|
||||||
|
|
||||||
var tot = 0;
|
var tot = 0;
|
||||||
log();
|
log();
|
||||||
log( chalk.cyan('KEYWORDS (') + chalk.cyan.bold( info.keywords.length ) +
|
log( chalk.cyan.bold('KEYWORDS') + chalk.cyan(' (') + chalk.white.bold( info.keywords.length ) +
|
||||||
chalk.cyan('):\n\n') +
|
chalk.cyan('):\n\n') +
|
||||||
info.keywords.map(function(g) {
|
info.keywords.map(function(g) {
|
||||||
tot += g.count;
|
tot += g.count;
|
||||||
return chalk.cyan( pad(g.name + ': ', padding) ) + chalk.cyan.bold( pad( g.count.toString(), 4 )) + chalk.cyan(' mentions');
|
return chalk.cyan( pad(g.name + ': ', padding) ) + chalk.cyan.bold( pad( g.count.toString(), 4 )) + chalk.cyan(' mentions');
|
||||||
}).join('\n'));
|
}).join('\n'));
|
||||||
|
|
||||||
console.log(chalk.cyan( pad('TOTAL: ', padding) ) + chalk.white.bold( pad( tot.toString(), 4 )) + chalk.cyan(' mentions'));
|
log(chalk.cyan( pad('TOTAL: ', padding) ) + chalk.white.bold( pad( tot.toString(), 4 )) + chalk.cyan(' mentions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,7 +96,7 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
function _loadInspectors() {
|
function _loadInspectors() {
|
||||||
return {
|
return {
|
||||||
totals: require('../inspectors/totals-inspector'),
|
totals: require('../inspectors/totals-inspector'),
|
||||||
gaps: require('../inspectors/gap-inspector'),
|
coverage: require('../inspectors/gap-inspector'),
|
||||||
keywords: require('../inspectors/keyword-inspector')
|
keywords: require('../inspectors/keyword-inspector')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user