Skip to content

Commit 42f249d

Browse files
author
Andreas Müller
committed
stats per day
1 parent b4010cc commit 42f249d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/output/base.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ class base {
113113
let projects = {};
114114
let times = [];
115115
let timesWarnings = [];
116+
let days = {};
117+
let daysMoment = {};
116118

117119
let spentFreeLabels = this.config.get('freeLabels');
118120
if(undefined === spentFreeLabels) {
@@ -122,11 +124,20 @@ class base {
122124
['issues', 'mergeRequests'].forEach(type => {
123125
this.report[type].forEach(issue => {
124126
issue.times.forEach(time => {
127+
let dateGrp = time.date.format(this.config.get('dateFormatGroupReport'));
125128
if (!users[time.user]) users[time.user] = 0;
126129
if (!projects[time.project_namespace]) projects[time.project_namespace] = 0;
130+
if (!days[dateGrp]) {
131+
days[dateGrp] = {}
132+
daysMoment[dateGrp] = time.date;
133+
};
134+
if(!days[dateGrp][time.iid]) {
135+
days[dateGrp][time.iid] = 0;
136+
}
127137

128138
users[time.user] += time.seconds;
129139
projects[time.project_namespace] += time.seconds;
140+
days[dateGrp][time.iid] += time.seconds;
130141

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

176+
this.days = days;
177+
this.daysMoment = daysMoment;
165178
this.users = _.mapObject(users, user => this.config.toHumanReadable(user, 'stats'));
166179
this.projects = _.mapObject(projects, project => this.config.toHumanReadable(project, 'stats'));
167180
this.stats = {

src/output/invoice.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,22 @@ ${closing}
133133
makeRecords() {
134134
this.headline('Details');
135135

136-
let times = [this.config.get('recordColumns').map(c => c.replace('_', ' '))];
137-
this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
138-
136+
let times = [['date', 'iid', 'time']];
137+
let days = Object.keys(this.days);
138+
days.sort();
139+
days.forEach(
140+
k => {
141+
let day = this.days[k];
142+
let refD = this.daysMoment[k].format(this.config.get('dateFormat'));
143+
let iids = Object.keys(day);
144+
iids.sort();
145+
iids.forEach(
146+
iid => {
147+
times.push([refD, iid, this.config.toHumanReadable(day[iid], 'records')]);
148+
});
149+
});
150+
//let times = [this.config.get('recordColumns').map(c => c.replace('_', ' '))];
151+
//this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
139152
this.write(Table(times));
140153
}
141154
}

0 commit comments

Comments
 (0)