Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 10 additions & 4 deletions src/models/hasTimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class hasTimes extends Base {
constructor(config) {
super(config);
this.times = [];
this.timesWarnings = [];
}

/**
Expand Down Expand Up @@ -58,6 +59,7 @@ class hasTimes extends Base {
*/
getTimes() {
let times = [],
timesWarnings = [],
timeSpent = 0,
totalTimeSpent = 0,
timeUsers = {},
Expand Down Expand Up @@ -127,18 +129,22 @@ class hasTimes extends Base {
!(created.isSameOrAfter(moment(this.config.get('from'))) && created.isSameOrBefore(moment(this.config.get('to'))))
) return resolve();

// warn about difference, but do not correct as gitlab API
// stats forget the times after an issue is moved to another project.
let difference = this.data.time_stats.total_time_spent - totalTimeSpent,
note = Object.assign({noteable_type: this._typeSingular}, this.data);

times.unshift(new Time(Time.toHumanReadable(difference, this.config.get('hoursPerDay')), null, note, this, this.config));

note.timeWarning = {};
note.timeWarning['stats'] = this.data.time_stats.total_time_spent;
note.timeWarning['notes'] = totalTimeSpent;
timesWarnings.push(new Time(Time.toHumanReadable(difference, this.config.get('hoursPerDay')), null, note, this, this.config));
resolve();
}));

promise.then(() => {
_.each(timeUsers, (time, name) => this[`time_${name}`] = Time.toHumanReadable(time, this.config.get('hoursPerDay'), timeFormat));
this.timeSpent = timeSpent;
this.times = times
this.times = times;
this.timesWarnings = timesWarnings;
});

return promise;
Expand Down
11 changes: 11 additions & 0 deletions src/output/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class base {
this.write(this.formats.headline(string));
}

/**
* print a headline for warnings
* @param string
*/
warningHeadline(string) {
if (this.config.get('noWarnings')) return;
this.headline(string);
}
/**
* print a warning
* @param string
Expand Down Expand Up @@ -104,6 +112,7 @@ class base {
let users = {};
let projects = {};
let times = [];
let timesWarnings = [];

let spentFreeLabels = this.config.get('freeLabels');
if(undefined === spentFreeLabels) {
Expand Down Expand Up @@ -132,6 +141,7 @@ class base {
}
times.push(time);
});
issue.timesWarnings.forEach(warning => timesWarnings.push(warning));

totalEstimate += parseInt(issue.stats.time_estimate);
totalSpent += parseInt(issue.stats.total_time_spent);
Expand Down Expand Up @@ -164,6 +174,7 @@ class base {
this.spent = spent;
this.spentFree = spentFree;
this.totalSpent = totalSpent;
this.timesWarnings = timesWarnings;
}

/**
Expand Down
16 changes: 15 additions & 1 deletion src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,21 @@ ${closing}
<h1 style="page-break-before: always;"><br/><br/>Stundenrapport</h1>`;

this.headline('Total');
this.write(stats.substr(1));
//this.write(stats.substr(1));
this.write(this.config.toHumanReadable(this.spent, 'stats'));
this.write(this.config.toHumanReadable(this.spentFree, 'statsFree'));

// warnings
let warnings = '';

this.timesWarnings.forEach( warning => {
let stats = this.config.toHumanReadable(warning.data.timeWarning.stats, 'stats');
let notes = this.config.toHumanReadable(warning.data.timeWarning.notes, 'stats');
warnings += `\n* ${warning.data.iid} ${warning.data.title}: Difference between stats and notes of ${warning.time}.`;
warnings += `<br/>Stats: ${stats}, Notes: ${notes}`
});
this.warningHeadline('Warnings');
this.warning(warnings+'\n');
}

makeIssues() {
Expand Down