Skip to content

Instantly share code, notes, and snippets.

@jasperfurniss
Created June 2, 2021 16:58
Show Gist options
  • Select an option

  • Save jasperfurniss/f86031431074966d371e29d15d63672f to your computer and use it in GitHub Desktop.

Select an option

Save jasperfurniss/f86031431074966d371e29d15d63672f to your computer and use it in GitHub Desktop.
var buildRunwayData = function() {
var returnData = [];
// Loops over each sprint
$(".backlog-filter-condensed").each(function(i, item) {
// Only care about the first 2
if (i < 2) {
// Should look like this "Sprint 56 (08/08 - 08/14)"
var sprint = $(this).find(".backlog-filter-condensed-title").text();
returnData.push({
sprint: sprint,
stories: []
});
$(this).find("li.backlog-item-condensed:not(.finished)").each(function(index) {
var title = $(this).find("h4.backlog-item-title").first().text();
// Protect for empty li's
if (title.length > 0) {
// Add title
returnData[i].stories.push({
title: title,
assignee: "unassigned"
})
// Add person's name
if ($(this).find(".assignee img").attr("alt")) {
var assignee = $(this).find(".assignee img").attr("alt").replace("avatar", "")
returnData[i].stories[index].assignee = assignee;
}
}
})
}
});
return returnData;
}
var groupBy = function(xs, key) {
return xs.reduce(function(rv, x) {
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv;
}, {});
};
var formatRunwayData = function(data) {
var md = ""
$.each(data, function( index, sprint ) {
md += "\n\n" + "# " + sprint.sprint;
var people = groupBy(sprint.stories, 'assignee');
$.each(people, function( name, stories ) {
md += "\n\n" + "##### " + name + "\n"
$.each(stories, function( i, story ) {
md += "- " + story.title + "\n"
})
})
})
return md
}
var runwayData = buildRunwayData();
var formattedRunwayData = formatRunwayData(runwayData);
console.log(formattedRunwayData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment