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

Commit 26cd2df

Browse files
committed
Stats show full names in statistics
1 parent 07d28e3 commit 26cd2df

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

src/models/hasTimes.js

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

2021
/**
@@ -101,6 +102,7 @@ class hasTimes extends Base {
101102
// add to time spent & add to user specific time spent
102103
timeSpent += time.seconds;
103104
timeUsers[note.author.username] += time.seconds;
105+
this.fullNames[note.author.username] = note.author.name;
104106

105107
time.project_namespace = this.project_namespace;
106108
times.push(time);

src/models/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ class project extends Base {
6767
}
6868
}
6969

70-
module.exports = project;
70+
module.exports = project;

src/models/user.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const _ = require('underscore');
2+
3+
/**
4+
* user model
5+
*/
6+
class user {
7+
constructor(data = {}) {
8+
this.data = data;
9+
}
10+
11+
make(username) {
12+
let promise;
13+
14+
promise = this.get(`users?username=${username}`);
15+
16+
promise.then(user => {
17+
this.data = user.body;
18+
return promise;
19+
});
20+
21+
return promise;
22+
}
23+
24+
/*
25+
* properties
26+
*/
27+
28+
get id() {
29+
return this.data.id;
30+
}
31+
32+
get name() {
33+
return this.data.name;
34+
}
35+
36+
get state() {
37+
return this.data.state === "active" ? true : false;
38+
}
39+
40+
get avatar_url() {
41+
return this.data.avatar_url;
42+
}
43+
44+
get web_url() {
45+
return this.data.web_url;
46+
}
47+
}

src/output/base.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class base {
101101
let totalSpent = 0;
102102
let spent = 0;
103103
let users = {};
104+
let userNames = {};
104105
let projects = {};
105106
let times = [];
106107

@@ -110,6 +111,7 @@ class base {
110111
if (!users[time.user]) users[time.user] = 0;
111112
if (!projects[time.project_namespace]) projects[time.project_namespace] = 0;
112113

114+
userNames[time.user] = issue.fullNames[time.user];
113115
users[time.user] += time.seconds;
114116
projects[time.project_namespace] += time.seconds;
115117

@@ -142,6 +144,7 @@ class base {
142144
this.users = userArr;
143145

144146
this.projects = _.mapObject(projects, project => this.config.toHumanReadable(project, 'stats'));
147+
this.userNames = userNames;
145148
this.stats = {
146149
'total estimate': this.config.toHumanReadable(totalEstimate, 'stats'),
147150
'total spent': this.config.toHumanReadable(totalSpent, 'stats'),

src/output/markdown.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class markdown extends Base {
3131
}
3232

3333
for (let [name, time, seconds] of this.users) {
34-
stats += `\n* **${name}**: ${time}`;
34+
let fullName = this.userNames[name];
35+
stats += `\n* **${fullName}**: ${time}`;
3536
}
3637

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

0 commit comments

Comments
 (0)