-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (48 loc) · 1.3 KB
/
app.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var JiraClient = require('jira-connector');
var math = require('mathjs');
var program = require('commander');
program
.version('0.1.0')
.arguments('<domain> <auth> <begin> <end> <project> [type]')
.action(function (domain, auth, begin, end, project, type) {
domain = domain;
auth = auth;
begin = begin;
end = end;
project = project;
type = type;
})
.parse(process.argv);
var domain = program.args[0];
var auth = program.args[1];
var begin = program.args[2];
var end = program.args[3];
var project = program.args[4];
var type = program.args[5];
var jira = new JiraClient( {
host: domain+'.atlassian.net',
basic_auth: {
base64: auth
}
});
var jql = 'project="'+project+'" AND worklogDate >= '+begin+' AND worklogDate <= '+end
if(type != undefined) {
jql = jql+' AND issuetype IN('+type+')';
}
jira.search.search({
jql: jql,
maxResults: 100,
"fields": ["timespent"]
}, function(error, result) {
if(error == null && result != null) {
console.log('Periodo: '+begin+' até '+end);
console.log("Total issues: " +result.total);
var total;
result.issues.forEach(function(issue){
total = math.sum(total, issue.fields.timespent);
});
console.log("Total horas: " +math.ceil(math.divide(total,3600)));
} else {
console.log(error);
}
});