forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue.js
More file actions
96 lines (74 loc) · 1.93 KB
/
issue.js
File metadata and controls
96 lines (74 loc) · 1.93 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const _ = require('underscore');
const moment = require('moment');
const hasTimes = require('./hasTimes');
/**
* issue model
*/
class issue extends hasTimes {
constructor(config, data = {}) {
super(config);
this.data = data;
}
make(project, id) {
let promise = this.get(`projects/${encodeURIComponent(project)}/issues/${id}`);
promise.then(issue => this.data = issue.body);
return promise;
}
/*
* properties
*/
get iid() {
return this.data.iid;
}
get id() {
return this.data.id;
}
get title() {
return this.data.title;
}
get project_id() {
return this.data.project_id;
}
get description() {
return this.data.description;
}
get labels() {
let labels = _.difference(this.data.labels, this.config.get('excludeLabels'));
let include = this.config.get('includeLabels');
return include.length > 0 ? _.intersection(labels, include) : labels;
}
get milestone() {
return this.data.milestone ? this.data.milestone.title : null;
}
get assignee() {
return this.data.assignee ? this.data.assignee.username : null;
}
get author() {
return this.data.author.username;
}
get closed() {
return !!this.data.closed;
}
get updated_at() {
return moment(this.data.updated_at);
}
get created_at() {
return moment(this.data.created_at);
}
get state() {
return this.data.state;
}
get spent() {
return this.config.toHumanReadable(this.timeSpent);
}
get total_spent() {
return this.stats ? this.config.toHumanReadable(this.stats.total_time_spent) : null;
}
get total_estimate() {
return this.stats ? this.config.toHumanReadable(this.stats.time_estimate) : null;
}
get _type() {
return 'issues';
}
}
module.exports = issue;