Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jiraTimelogReport.js
var s=document.createElement('script');
s.setAttribute('src','https://code.jquery.com/jquery.js');
document.getElementsByTagName('body')[0].appendChild(s);
var issues = {};
(function($){
var issuetable = jQuery('#issuetable');
issuetable.find('tbody > .issuerow').each(function() {
var $row = jQuery(this);
$row.find('.parentIssue').remove();
var name = $row.find('td.issuekey').text().trim() + ' ' + $row.find('td.summary').text().trim();
$row.find('td.day').each(function() {
var $day = jQuery(this);
var time = $day.text().trim();
var issue = {};
if(time.length) {
issue.name = name;
issue.time = parseFloat(time);
var classes = $day.attr('class');
myRegexp = /\s+(\d+)\s+/g;
date = myRegexp.exec(classes)[1].trim();
if(typeof issues[date] === "undefined") issues[date] = [];
issues[date].push(issue);
}
});
});
for (var date in issues) {
if (issues.hasOwnProperty(date)) {
var projects = {};
console.log(date);
issues[date].forEach(function(issue) {
if(typeof projects[issue.name.substring(0,4)] === "undefined") projects[issue.name.substring(0,4)] = {name: '', time: 0, issues: []};
projects[issue.name.substring(0,4)].name += issue.name + "\n";
projects[issue.name.substring(0,4)].time += issue.time;
projects[issue.name.substring(0,4)].issues.push(issue);
});
console.log(projects);
for (var p in projects) {
if (projects.hasOwnProperty(p)) {
console.log(projects[p].name);
console.log(projects[p].time);
}
}
console.log("\n\n\n\n\n");
}
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.