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
stats per day
  • Loading branch information
Andreas Müller committed Mar 5, 2021
commit 42f249d3798a69dbe022aa3bb282f96cffef1ca1
13 changes: 13 additions & 0 deletions src/output/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class base {
let projects = {};
let times = [];
let timesWarnings = [];
let days = {};
let daysMoment = {};

let spentFreeLabels = this.config.get('freeLabels');
if(undefined === spentFreeLabels) {
Expand All @@ -122,11 +124,20 @@ class base {
['issues', 'mergeRequests'].forEach(type => {
this.report[type].forEach(issue => {
issue.times.forEach(time => {
let dateGrp = time.date.format(this.config.get('dateFormatGroupReport'));
if (!users[time.user]) users[time.user] = 0;
if (!projects[time.project_namespace]) projects[time.project_namespace] = 0;
if (!days[dateGrp]) {
days[dateGrp] = {}
daysMoment[dateGrp] = time.date;
};
if(!days[dateGrp][time.iid]) {
days[dateGrp][time.iid] = 0;
}

users[time.user] += time.seconds;
projects[time.project_namespace] += time.seconds;
days[dateGrp][time.iid] += time.seconds;

spent += time.seconds;
//if(time.parent.labels)
Expand Down Expand Up @@ -162,6 +173,8 @@ class base {
return a.date.isBefore(b.date) ? 1 : -1;
});

this.days = days;
this.daysMoment = daysMoment;
this.users = _.mapObject(users, user => this.config.toHumanReadable(user, 'stats'));
this.projects = _.mapObject(projects, project => this.config.toHumanReadable(project, 'stats'));
this.stats = {
Expand Down
19 changes: 16 additions & 3 deletions src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,22 @@ ${closing}
makeRecords() {
this.headline('Details');

let times = [this.config.get('recordColumns').map(c => c.replace('_', ' '))];
this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));

let times = [['date', 'iid', 'time']];
let days = Object.keys(this.days);
days.sort();
days.forEach(
k => {
let day = this.days[k];
let refD = this.daysMoment[k].format(this.config.get('dateFormat'));
let iids = Object.keys(day);
iids.sort();
iids.forEach(
iid => {
times.push([refD, iid, this.config.toHumanReadable(day[iid], 'records')]);
});
});
//let times = [this.config.get('recordColumns').map(c => c.replace('_', ' '))];
//this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
this.write(Table(times));
}
}
Expand Down