Skip to content

Commit 8c835d7

Browse files
committed
Add description parsing kriskbx#27
1 parent 0833099 commit 8c835d7

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

readme.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ includeLabels:
603603
- pending
604604
- approved
605605

606+
# Only works if using a local configuration file!
607+
# Extend the global configuration if set to true, pass a string to extend
608+
# the configuration file stored at the given path
609+
# defaults to true
610+
extend: true
611+
606612
# Change number of concurrent connections/http queries
607613
# Note: Handle with care, we don't want to spam GitLabs API too much
608614
# defaults to 10
@@ -612,11 +618,14 @@ _parallel: 20
612618
# defaults to 100
613619
_perPage: 100
614620

615-
# Only works if using a local configuration file!
616-
# Extend the global configuration if set to true, pass a string to extend
617-
# the configuration file stored at the given path
618-
# defaults to true
619-
extend: true
621+
# Verbose output
622+
_verbose: false
623+
624+
# Check access token validity up front
625+
_checkToken: false
626+
627+
# Skip parsing the issue/merge_request description for time records
628+
_skipDescriptionParsing: false
620629
```
621630
622631
### Time format

src/include/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const defaults = {
3838
_perPage: 100,
3939
_parallel: 10,
4040
_verbose: false,
41-
_checkToken: false
41+
_checkToken: false,
42+
_skipDescriptionParsing: false
4243
};
4344

4445
/**

src/models/hasTimes.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class hasTimes extends Base {
1515
constructor(config) {
1616
super(config);
1717
this.times = [];
18-
this.name = '';
1918
}
2019

2120
/**
@@ -59,7 +58,7 @@ class hasTimes extends Base {
5958
let times = [],
6059
timeSpent = 0,
6160
timeUsers = {},
62-
timeFormat = this.config.get('timeFormat', this.name);
61+
timeFormat = this.config.get('timeFormat', this._type);
6362

6463
// sort by created at
6564
this.notes.sort((a, b) => {
@@ -95,6 +94,17 @@ class hasTimes extends Base {
9594
done();
9695
});
9796

97+
promise = promise.then(() => new Promise(resolve => {
98+
if (this.config('_skipDescriptionParsing') || timeSpent === this.data.time_stats.total_time_spent) return resolve();
99+
100+
let difference = this.data.time_stats.total_time_spent - timeSpent,
101+
note = Object.assign({noteable_type: this._typeSingular}, this.data);
102+
103+
times.unshift(new Time(Time.toHumanReadable(difference, this.config.get('hoursPerDay')), note, this, this.config));
104+
105+
resolve();
106+
}));
107+
98108
promise.then(() => {
99109
_.each(timeUsers, (time, name) => this[`time_${name}`] = Time.toHumanReadable(time, this.config.get('hoursPerDay'), timeFormat));
100110
this.timeSpent = timeSpent;

src/models/issue.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class issue extends hasTimes {
1010
constructor(config, data = {}) {
1111
super(config);
1212
this.data = data;
13-
this.name= 'issues';
1413
}
1514

1615
make(project, id, create = false) {
@@ -88,20 +87,24 @@ class issue extends hasTimes {
8887
}
8988

9089
get spent() {
91-
return this.config.toHumanReadable(this.timeSpent, this.name);
90+
return this.config.toHumanReadable(this.timeSpent, this._type);
9291
}
9392

9493
get total_spent() {
95-
return this.stats ? this.config.toHumanReadable(this.stats.total_time_spent, this.name) : null;
94+
return this.stats ? this.config.toHumanReadable(this.stats.total_time_spent, this._type) : null;
9695
}
9796

9897
get total_estimate() {
99-
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this.name) : null;
98+
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
10099
}
101100

102101
get _type() {
103102
return 'issues';
104103
}
104+
105+
get _typeSingular() {
106+
return 'Issue';
107+
}
105108
}
106109

107110
module.exports = issue;

src/models/mergeRequest.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class mergeRequest extends hasTimes {
77
constructor(config, data = {}) {
88
super(config);
99
this.data = data;
10-
this.name = 'merge_requests';
1110
}
1211

1312
make(project, id, create = false) {
@@ -81,20 +80,24 @@ class mergeRequest extends hasTimes {
8180
}
8281

8382
get spent() {
84-
return this.config.toHumanReadable(this.timeSpent, this.name);
83+
return this.config.toHumanReadable(this.timeSpent, this._type);
8584
}
8685

8786
get total_spent() {
88-
return this.stats ? this.config.toHumanReadable(this.stats.total_time_spent, this.name) : null;
87+
return this.stats ? this.config.toHumanReadable(this.stats.total_time_spent, this._type) : null;
8988
}
9089

9190
get total_estimate() {
92-
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this.name) : null;
91+
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate, this._type) : null;
9392
}
9493

9594
get _type() {
9695
return 'merge_requests';
9796
}
97+
98+
get _typeSingular() {
99+
return 'Merge Request';
100+
}
98101
}
99102

100103
module.exports = mergeRequest;

0 commit comments

Comments
 (0)