forked from drone/drone-wall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
37 lines (26 loc) · 988 Bytes
/
api.js
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
'use strict';
var capitalizeFirstChar = require('./utils').capitalizeFirstChar;
var oldApiMapper = function (gravatarCalculator) {
return function (builds) {
return builds.map(function (build) {
build.updated_at = Math.max(
build.created_at,
build.enqueued_at,
build.started_at,
build.finished_at
);
build.duration = build.started_at && build.finished_at
? build.started_at - build.finished_at
: 0;
build.status = build.status.toLowerCase();
if (build.status == 'running') {
build.status = 'started';
}
build.status = capitalizeFirstChar(build.status);
build.sha = build.created_at + build.commit;
build.gravatar = gravatarCalculator.getByEmail(build.author_email);
return build;
});
};
};
module.exports = oldApiMapper;