mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-10-30 20:57:26 +00:00 
			
		
		
		
	Add overlap analysis.
This commit is contained in:
		| @@ -59,23 +59,55 @@ Employment gap analysis for HackMyResume. | ||||
|       // 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. | ||||
|       // 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) { | ||||
|         var inc = point[0] === 'start' ? 1 : -1; | ||||
|         ref_count += inc; | ||||
|         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 ) { | ||||
|           var lastGap = _.last( gaps ); | ||||
|           var lastGap = _.last( coverage.gaps ); | ||||
|           if( lastGap ) { | ||||
|             lastGap.end = point[1]; | ||||
|             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 ); | ||||
|     }); | ||||
|  | ||||
|     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'); | ||||
|     _.each( info.totals, function(tot, key) { | ||||
|       log(chalk.cyan(pad(key + ': ',20)) + chalk.cyan.bold(pad(tot.toString(),4))); | ||||
|     }); | ||||
|  | ||||
|     log(); | ||||
|     log(chalk.cyan('GAPS (') + chalk.cyan.bold(info.gaps.length) + chalk.cyan('):\n')); | ||||
|     log(chalk.cyan(pad('Lengths:    ', padding + 3)) + info.gaps.map(function(g) { | ||||
|     log(chalk.cyan.bold('COVERAGE') + chalk.cyan(' (') + chalk.white.bold( info.coverage.pct ) + chalk.cyan('):\n')); | ||||
|     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'; | ||||
|         if( g.duration > 35 ) clr = 'yellow'; | ||||
|         if( g.duration > 90 ) clr = 'red'; | ||||
|         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; | ||||
|     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') + | ||||
|       info.keywords.map(function(g) { | ||||
|         tot += g.count; | ||||
|         return chalk.cyan( pad(g.name + ': ', padding) ) + chalk.cyan.bold( pad( g.count.toString(), 4 )) + chalk.cyan(' mentions'); | ||||
|       }).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() { | ||||
|     return { | ||||
|       totals: require('../inspectors/totals-inspector'), | ||||
|       gaps: require('../inspectors/gap-inspector'), | ||||
|       coverage: require('../inspectors/gap-inspector'), | ||||
|       keywords: require('../inspectors/keyword-inspector') | ||||
|     }; | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user