Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit e7cbfa9

Browse files
author
Isaac Würth
committed
partial: adding milestone to charts
1 parent b89a8b2 commit e7cbfa9

File tree

6 files changed

+67
-32
lines changed

6 files changed

+67
-32
lines changed

src/gtt-report.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ program
6565
.option('--verbose', 'show verbose output')
6666
.option('--show_without_times', 'show issues/merge requests without time records')
6767
.option('--from_dump <file>', 'instead of querying gitlab, use data from the given dump file')
68+
.option('--tag <tag>', 'timeperiod until this tag')
6869
.parse(process.argv);
6970

7071
// init helpers
@@ -123,9 +124,11 @@ config
123124
.set('proxy', program.proxy)
124125
.set('type', program.type)
125126
.set('subgroups', program.subgroups)
127+
.set('tag', program.tag)
126128
.set('_verbose', program.verbose)
127129
.set('_createDump', program.output === 'dump');
128130

131+
129132
// date shortcuts
130133
if (program.today)
131134
config
@@ -228,7 +231,6 @@ new Promise(resolve => {
228231
});
229232
}))
230233
.then(() => Cli.out(`\r${Cli.look} Selected projects: ${reports.reports.map(r => r.project.name.bold.blue).join(', ')}\n`))
231-
232234
// get members and user columns
233235
.then(() => new Promise(resolve => {
234236
if (!config.get('userColumns')) return resolve();

src/include/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const defaults = {
4040
quiet: false,
4141
showWithoutTimes: false,
4242
timezone: "UTC",
43+
tag: '',
4344
_perPage: 100,
4445
_parallel: 10,
4546
_verbose: false,

src/models/milestone.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const _ = require('underscore');
21
const moment = require('moment');
32

43
const hasTimes = require('./hasTimes');
@@ -13,8 +12,8 @@ class milestone extends hasTimes {
1312
this.data = data;
1413
this.stats = {
1514
spent : 0,
16-
total_spent : 0,
17-
time_estimate : 0
15+
time_estimate : 0,
16+
total_time_spent : 0
1817
}
1918
}
2019

@@ -86,12 +85,12 @@ class milestone extends hasTimes {
8685
return this.stats ? this.config.toHumanReadable(this.stats.spent, this._type) : null;
8786
}
8887

89-
get total_spent() {
90-
return this.stats ? this.config.toHumanReadable(this.stats.total_spent, this._type) : null;
88+
get time_estimate() {
89+
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
9190
}
9291

9392
get total_estimate() {
94-
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
93+
return this.stats ? this.config.toHumanReadable(this.stats.total_estimate, this._type) : null;
9594
}
9695

9796
get _type() {
@@ -103,38 +102,37 @@ class milestone extends hasTimes {
103102
}
104103

105104
getIssues(){
106-
let promise = new Promise(resolve => {
105+
return new Promise(resolve => {
107106
this.get(`projects/${encodeURIComponent(this.project_id)}/issues/?milestone=${this.title}`)
108107
.then(data => data.body)
109108
.then(rawIssues => {
110109
let issues = []
111-
rawIssues.forEach(data => {
110+
rawIssues.forEach(data => {
112111
let issue = new Issue(this.config, data)
113112
issues.push(issue)
114113
})
115114
this.issues = issues
116115
resolve()
117116
})
118117
})
119-
120-
return promise
121118
}
122119

123120
getStats(){
124-
let promise = new Promise((resolve) => {
125-
this.issues.forEach(async issue => {
126-
await issue.getStats()
127-
this.stats.time_estimate += issue.total_estimate;
128-
this.stats.total_spent += issue.total_spent;
129-
this.stats.spent += issue.spent;
130-
})
131-
resolve()
121+
return new Promise((resolve) => {
122+
this.parallel(this.issues, (issue, done) => {
123+
issue.getStats()
124+
.then(() => {
125+
this.stats.time_estimate += issue.stats.time_estimate;
126+
this.stats.total_time_spent += issue.stats.total_time_spent;
127+
this.stats.spent += issue.spent;
128+
return done();
129+
})
130+
}).then(() => resolve())
132131
})
133-
return promise
134132
}
135133

136134
async getNotes(){
137-
let promise = new Promise(async resolve => {
135+
return new Promise(async resolve => {
138136
await this.getIssues();
139137
this.notes = [];
140138
for (const issue of this.issues) {
@@ -143,9 +141,6 @@ class milestone extends hasTimes {
143141
}
144142
resolve()
145143
})
146-
147-
148-
return promise
149144
}
150145

151146
}

src/models/report.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
const _ = require('underscore');
2-
const moment = require('moment');
3-
41
const Base = require('./base');
52
const Issue = require('./issue');
63
const MergeRequest = require('./mergeRequest');
@@ -169,7 +166,7 @@ class report extends Base {
169166
* process issues
170167
* @param advance
171168
* @returns {Promise}
172-
*/
169+
*/0
173170
processIssues(advance = false) {
174171
return this.process('issues', Issue, advance);
175172
}

src/output/charts.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
const _ = require('underscore');
2-
3-
const Table = require('markdown-table');
41
const Base = require('./base');
52
const ChartJsImage = require('chartjs-to-image');
6-
const Time = require('./../models/time');
73

84
const format = {
95
headline: h => `\n## ${h}\n`,
@@ -60,6 +56,10 @@ class chart extends Base {
6056

6157
getMemeberLink() {
6258
const memberStats = new ChartJsImage();
59+
let milestones = {}
60+
this.report.milestones.forEach(milestone => {
61+
milestones[milestone.title] = milestone.stats;
62+
})
6363
memberStats.setConfig({
6464
type: 'bar',
6565
data: {
@@ -91,6 +91,40 @@ class chart extends Base {
9191
return memberStats.getUrl();
9292
}
9393

94+
getMilestoneLink(){
95+
const memberStats = new ChartJsImage();
96+
memberStats.setConfig({
97+
type: 'bar',
98+
data: {
99+
labels: Object.keys(this.users),
100+
datasets: [
101+
{ label: '[h]', data: Object.values(this.users)},
102+
]
103+
},
104+
options: {
105+
responsive: true,
106+
legend: {
107+
position: "top"
108+
},
109+
title: {
110+
display: true,
111+
text: "Members"
112+
},
113+
plugins: {
114+
datalabels: {
115+
display: true,
116+
align: 'bottom',
117+
backgroundColor: '#ccc',
118+
borderRadius: 3
119+
},
120+
}
121+
}
122+
});
123+
124+
return memberStats.getUrl();
125+
126+
}
127+
94128
makeStats() {}
95129

96130
makeIssues() {}

src/output/epj.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class epj extends Base {
4040
stats += `\n`;
4141
stats += "\n\n![alt Memebrs](" + this.chart.getMemeberLink() + ' "Members")\n\n'
4242

43+
this.headline('Milestones')
44+
45+
stats += `\n`;s
46+
stats += "\n\n![alt Milestone](" + this.chart.getMilestoneLink() + ' "Milestone")\n\n'
47+
48+
4349
this.write(stats.substr(1));
4450
}
4551

0 commit comments

Comments
 (0)