Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support half-price labels
  • Loading branch information
Andreas Müller committed Sep 28, 2022
commit cf1ec45ea8c0a09d9688fab8144edab650025c31
16 changes: 16 additions & 0 deletions src/output/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class base {
let totalSpent = 0;
let spent = 0;
let spentFree = 0;
let spentHalfPrice = 0;
let users = {};
let projects = {};
let times = [];
Expand All @@ -120,6 +121,10 @@ class base {
if(undefined === spentFreeLabels) {
spentFreeLabels = [];
}
let spentHalfPriceLabels = this.config.get('halfPriceLabels');
if(undefined === spentHalfPriceLabels) {
spentHalfPriceLabels = [];
}

['issues', 'mergeRequests'].forEach(type => {
this.report[type].forEach(issue => {
Expand All @@ -146,14 +151,24 @@ class base {
spent += time.seconds;
//if(time.parent.labels)
let free = false;
let halfPrice = false;
time.parent.labels.forEach(label => {
spentFreeLabels.forEach(freeLabel => {
free |= (freeLabel == label);
});
});
time.parent.labels.forEach(label => {
spentHalfPriceLabels.forEach(halfPriceLabel => {
halfPrice |= (halfPriceLabel == label);
});
});

if(free) {
spentFree += time.seconds;
}
if(halfPrice) {
spentHalfPrice += time.seconds;
}
times.push(time);
});
issue.timesWarnings.forEach(warning => timesWarnings.push(warning));
Expand Down Expand Up @@ -190,6 +205,7 @@ class base {
this.totalEstimate = totalEstimate;
this.spent = spent;
this.spentFree = spentFree;
this.spentHalfPrice = spentHalfPrice;
this.totalSpent = totalSpent;
this.timesWarnings = timesWarnings;
}
Expand Down
1 change: 1 addition & 0 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ ${closing}
this.headline('Total');
//this.write(stats.substr(1));
this.write(this.config.toHumanReadable(this.spent, 'stats'));
this.write(this.config.toHumanReadable(this.spentHalfPrice, 'statsHalfPrice'));
this.write(this.config.toHumanReadable(this.spentFree, 'statsFree'));

// warnings
Expand Down