diff --git a/src/gtt-report.js b/src/gtt-report.js index 29303fb..82c9bad 100755 --- a/src/gtt-report.js +++ b/src/gtt-report.js @@ -42,6 +42,7 @@ program .option('--today', 'ignores --from and --to and queries entries for today') .option('--this_week', 'ignores --from and --to and queries entries for this week') .option('--this_month', 'ignores --from and --to and queries entries for this month') + .option('--last_month', 'ignores --from and --to and queries entries for last month') .option('-c --closed', 'include closed issues') .option('-m --milestone ', 'include issues from the given milestone') .option('--hours_per_day ', 'hours per day for human readable time formats') @@ -168,6 +169,10 @@ if (program.opts().this_month) config .set('from', moment().startOf('month')) .set('to', moment().endOf('month')); +if (program.opts().last_month) + config + .set('from', moment().subtract(1, 'months').startOf('month')) + .set('to', moment().subtract(1, 'months').endOf('month')); Cli.quiet = config.get('quiet'); Cli.verbose = config.get('_verbose'); diff --git a/src/output/base.js b/src/output/base.js index 219877c..030f7ad 100755 --- a/src/output/base.js +++ b/src/output/base.js @@ -171,8 +171,10 @@ class base { projects[time.project_namespace] += time.seconds; days[dateGrp][time.project_namespace][time.iid] += time.seconds; - spent += time.seconds; - + if (Math.sign(time.seconds) === 1) { + spent += time.seconds; + } + if(free) { spentFree += time.seconds; } @@ -208,7 +210,7 @@ class base { this.projects = _.mapObject(projects, project => this.config.toHumanReadable(project, 'stats')); this.stats = { 'total estimate': this.config.toHumanReadable(totalEstimate, 'stats'), - 'total spent': this.config.toHumanReadable(totalSpent, 'stats'), + 'total spent': this.config.toHumanReadable(spent, 'stats'), 'spent': this.config.toHumanReadable(spent, 'stats'), 'spent free': this.config.toHumanReadable(spentFree, 'stats'), }; @@ -216,7 +218,7 @@ class base { this.spent = spent; this.spentFree = spentFree; this.spentHalfPrice = spentHalfPrice; - this.totalSpent = totalSpent; + this.totalSpent = spent; this.timesWarnings = timesWarnings; this.daysNew = daysNew; } @@ -242,4 +244,4 @@ class base { } } -module.exports = base; \ No newline at end of file +module.exports = base;