Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created May 15, 2017 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbrown/d8e0ae7e4d2119f3820c04112c866aa7 to your computer and use it in GitHub Desktop.
Save bbrown/d8e0ae7e4d2119f3820c04112c866aa7 to your computer and use it in GitHub Desktop.
Use JIRA's list of versions to get some quick and dirty date-based release counts
var versions = "Array from https://jira/rest/api/2/project/projectKey/versions";
var dateRegex = /([0-9]{4})([0-9]{2})([0-9]{2})[0-9]{4}/;
var counts = {};
versions.forEach(function(version)
{
if (dateRegex.test(version.name))
{
var dateParts = dateRegex.exec(version.name);
var yearKey = "" + dateParts[1];
var monthKey = "" + dateParts[1] + "-" + dateParts[2];
var dayKey = "" + dateParts[1] + "-" + dateParts[2] + "-" + dateParts[3];
if (!counts[yearKey])
{
counts[yearKey] = 1;
}
else
{
counts[yearKey]++;
}
if (!counts[monthKey])
{
counts[monthKey] = 1;
}
else
{
counts[monthKey]++;
}
if (!counts[dayKey])
{
counts[dayKey] = 1;
}
else
{
counts[dayKey]++;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment