Skip to content

Commit 07d28e3

Browse files
committed
Output: sort user list by time
1 parent e059f1f commit 07d28e3

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

src/models/owner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ class owner extends Base {
131131
}
132132
}
133133

134-
module.exports = owner;
134+
module.exports = owner;

src/output/base.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ class base {
136136
return a.date.isBefore(b.date) ? 1 : -1;
137137
});
138138

139-
this.users = _.mapObject(users, user => this.config.toHumanReadable(user, 'stats'));
139+
let userArr = [];
140+
_.each(users, (time, name) => userArr.push([name, this.config.toHumanReadable(time, 'stats'), time]));
141+
userArr = userArr.sort((a,b) => b[2] - a[2]);
142+
this.users = userArr;
143+
140144
this.projects = _.mapObject(projects, project => this.config.toHumanReadable(project, 'stats'));
141145
this.stats = {
142146
'total estimate': this.config.toHumanReadable(totalEstimate, 'stats'),
@@ -166,4 +170,4 @@ class base {
166170
}
167171
}
168172

169-
module.exports = base;
173+
module.exports = base;

src/output/csv.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class csv extends Base {
2424
});
2525
}
2626

27-
_.each(this.users, (time, name) => {
27+
for (let [name, time, seconds] of this.users) {
2828
stats[0].push(name);
2929
stats[1].push(time);
30-
});
30+
}
3131

3232
this.csvStats = Csv.stringify(stats);
3333
}
@@ -101,4 +101,4 @@ class csv extends Base {
101101
}
102102
}
103103

104-
module.exports = csv;
104+
module.exports = csv;

src/output/markdown.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class markdown extends Base {
3030
stats += `\n`;
3131
}
3232

33-
_.each(this.users, (time, name) => stats += `\n* **${name}**: ${time}`);
33+
for (let [name, time, seconds] of this.users) {
34+
stats += `\n* **${name}**: ${time}`;
35+
}
3436

3537
this.write(stats.substr(1));
3638
}
@@ -69,4 +71,4 @@ class markdown extends Base {
6971
}
7072
}
7173

72-
module.exports = markdown;
74+
module.exports = markdown;

src/output/table.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class table extends Base {
3030
stats += `\n`;
3131
}
3232

33-
_.each(this.users, (time, name) => stats += `\n* ${name.red}: ${time}`);
33+
for (let [name, time, seconds] of this.users) {
34+
stats += `\n* ${name.red}: ${time}`;
35+
}
3436

3537
this.write(stats.substr(1));
3638
}
@@ -65,4 +67,4 @@ class table extends Base {
6567
}
6668
}
6769

68-
module.exports = table;
70+
module.exports = table;

src/output/xlsx.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class xlsx extends Base {
2626
});
2727
}
2828

29-
_.each(this.users, (time, name) => {
29+
for (let [name, time, seconds] of this.users) {
3030
stats[0].push(name);
3131
stats[1].push(time);
32-
});
32+
}
3333

3434
this.xlsxStats = XLSX.utils.aoa_to_sheet(stats);
3535
}

0 commit comments

Comments
 (0)