forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.js
More file actions
61 lines (47 loc) · 1.79 KB
/
table.js
File metadata and controls
61 lines (47 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const _ = require('underscore');
const Table = require('cli-table');
const Base = require('./base');
const Color = require('colors');
const format = {
headline: h => `\n${h.bold.underline}\n`,
warning: w => w.yellow
};
/**
* stdout table output
*/
class table extends Base {
constructor(config, report) {
super(config, report);
this.format = format;
}
makeStats() {
this.headline('TIME STATS');
let stats = '';
_.each(this.stats, (time, name) => stats += `\n* ${name.red}: ${time}`);
_.each(this.users, (time, name) => stats += `\n* ${name.red}: ${time}`);
this.write(stats.substr(1));
}
makeIssues() {
this.headline('ISSUES');
if (this.report.issues.length === 0)
return this.warning('No issues found');
let issues = new Table({head: this.config.get('issueColumns')});
this.report.issues.forEach(issue => issues.push(this.prepare(issue, this.config.get('issueColumns'))));
this.write(issues.toString());
}
makeMergeRequests() {
this.headline('MERGE REQUESTS');
if (this.report.mergeRequests.length === 0)
return this.warning('No merge requests found');
let mergeRequests = new Table({head: this.config.get('mergeRequestColumns')});
this.report.mergeRequests.forEach(mergeRequest => mergeRequests.push(this.prepare(mergeRequest, this.config.get('mergeRequestColumns'))));
this.write(mergeRequests.toString());
}
makeRecords() {
this.headline('TIME RECORDS');
let times = new Table({head: this.config.get('recordColumns')});
this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
this.write(times.toString());
}
}
module.exports = table;