Created
June 2, 2021 16:58
-
-
Save jasperfurniss/f86031431074966d371e29d15d63672f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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