Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Closed
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
partial: adding milestone to charts
  • Loading branch information
Isaac Würth committed Mar 9, 2021
commit e7cbfa934768434a70d77fda718f86f55c3a9d3e
4 changes: 3 additions & 1 deletion src/gtt-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ program
.option('--verbose', 'show verbose output')
.option('--show_without_times', 'show issues/merge requests without time records')
.option('--from_dump <file>', 'instead of querying gitlab, use data from the given dump file')
.option('--tag <tag>', 'timeperiod until this tag')
.parse(process.argv);

// init helpers
Expand Down Expand Up @@ -123,9 +124,11 @@ config
.set('proxy', program.proxy)
.set('type', program.type)
.set('subgroups', program.subgroups)
.set('tag', program.tag)
.set('_verbose', program.verbose)
.set('_createDump', program.output === 'dump');


// date shortcuts
if (program.today)
config
Expand Down Expand Up @@ -228,7 +231,6 @@ new Promise(resolve => {
});
}))
.then(() => Cli.out(`\r${Cli.look} Selected projects: ${reports.reports.map(r => r.project.name.bold.blue).join(', ')}\n`))

// get members and user columns
.then(() => new Promise(resolve => {
if (!config.get('userColumns')) return resolve();
Expand Down
1 change: 1 addition & 0 deletions src/include/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const defaults = {
quiet: false,
showWithoutTimes: false,
timezone: "UTC",
tag: '',
_perPage: 100,
_parallel: 10,
_verbose: false,
Expand Down
41 changes: 18 additions & 23 deletions src/models/milestone.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const _ = require('underscore');
const moment = require('moment');

const hasTimes = require('./hasTimes');
Expand All @@ -13,8 +12,8 @@ class milestone extends hasTimes {
this.data = data;
this.stats = {
spent : 0,
total_spent : 0,
time_estimate : 0
time_estimate : 0,
total_time_spent : 0
}
}

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

get total_spent() {
return this.stats ? this.config.toHumanReadable(this.stats.total_spent, this._type) : null;
get time_estimate() {
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
}

get total_estimate() {
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
return this.stats ? this.config.toHumanReadable(this.stats.total_estimate, this._type) : null;
}

get _type() {
Expand All @@ -103,38 +102,37 @@ class milestone extends hasTimes {
}

getIssues(){
let promise = new Promise(resolve => {
return new Promise(resolve => {
this.get(`projects/${encodeURIComponent(this.project_id)}/issues/?milestone=${this.title}`)
.then(data => data.body)
.then(rawIssues => {
let issues = []
rawIssues.forEach(data => {
rawIssues.forEach(data => {
let issue = new Issue(this.config, data)
issues.push(issue)
})
this.issues = issues
resolve()
})
})

return promise
}

getStats(){
let promise = new Promise((resolve) => {
this.issues.forEach(async issue => {
await issue.getStats()
this.stats.time_estimate += issue.total_estimate;
this.stats.total_spent += issue.total_spent;
this.stats.spent += issue.spent;
})
resolve()
return new Promise((resolve) => {
this.parallel(this.issues, (issue, done) => {
issue.getStats()
.then(() => {
this.stats.time_estimate += issue.stats.time_estimate;
this.stats.total_time_spent += issue.stats.total_time_spent;
this.stats.spent += issue.spent;
return done();
})
}).then(() => resolve())
})
return promise
}

async getNotes(){
let promise = new Promise(async resolve => {
return new Promise(async resolve => {
await this.getIssues();
this.notes = [];
for (const issue of this.issues) {
Expand All @@ -143,9 +141,6 @@ class milestone extends hasTimes {
}
resolve()
})


return promise
}

}
Expand Down
5 changes: 1 addition & 4 deletions src/models/report.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const _ = require('underscore');
const moment = require('moment');

const Base = require('./base');
const Issue = require('./issue');
const MergeRequest = require('./mergeRequest');
Expand Down Expand Up @@ -169,7 +166,7 @@ class report extends Base {
* process issues
* @param advance
* @returns {Promise}
*/
*/0
processIssues(advance = false) {
return this.process('issues', Issue, advance);
}
Expand Down
42 changes: 38 additions & 4 deletions src/output/charts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const _ = require('underscore');

const Table = require('markdown-table');
const Base = require('./base');
const ChartJsImage = require('chartjs-to-image');
const Time = require('./../models/time');

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

getMemeberLink() {
const memberStats = new ChartJsImage();
let milestones = {}
this.report.milestones.forEach(milestone => {
milestones[milestone.title] = milestone.stats;
})
memberStats.setConfig({
type: 'bar',
data: {
Expand Down Expand Up @@ -91,6 +91,40 @@ class chart extends Base {
return memberStats.getUrl();
}

getMilestoneLink(){
const memberStats = new ChartJsImage();
memberStats.setConfig({
type: 'bar',
data: {
labels: Object.keys(this.users),
datasets: [
{ label: '[h]', data: Object.values(this.users)},
]
},
options: {
responsive: true,
legend: {
position: "top"
},
title: {
display: true,
text: "Members"
},
plugins: {
datalabels: {
display: true,
align: 'bottom',
backgroundColor: '#ccc',
borderRadius: 3
},
}
}
});

return memberStats.getUrl();

}

makeStats() {}

makeIssues() {}
Expand Down
6 changes: 6 additions & 0 deletions src/output/epj.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class epj extends Base {
stats += `\n`;
stats += "\n\n![alt Memebrs](" + this.chart.getMemeberLink() + ' "Members")\n\n'

this.headline('Milestones')

stats += `\n`;s
stats += "\n\n![alt Milestone](" + this.chart.getMilestoneLink() + ' "Milestone")\n\n'


this.write(stats.substr(1));
}

Expand Down