Skip to content

Instantly share code, notes, and snippets.

@hswolff
Created April 3, 2018 14:27
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 hswolff/fe0575267ead42a8dbdf7cbb41ace117 to your computer and use it in GitHub Desktop.
Save hswolff/fe0575267ead42a8dbdf7cbb41ace117 to your computer and use it in GitHub Desktop.
Little Script to Rank to Top issues in a Jira Epic
async function rankNonDoneIssuesToTopInEpic(dryRun = true) {
console.warn(`Dry Run: ${dryRun ? 'ENABLED' : 'DISABLED'}`);
const issuesInEpic = Array.from(document.querySelectorAll('.nav.status'))
.filter(el => !['Resolved', 'Closed'].includes(el.textContent.trim()))
// Go from bottom up so the order remains the same
.reverse();
const sleep = (time = 1000) =>
new Promise(resolve => setTimeout(resolve, time));
for (const el of issuesInEpic) {
const rowEl = el.parentElement;
const data = {
ticketNumber: rowEl.getAttribute('data-issuekey'),
summary: rowEl.querySelector('.ghx-summary').textContent.trim(),
};
const message = `${data.ticketNumber}: ${data.summary}`;
console.group(message);
console.log('Updating');
// Open gear menu
rowEl.querySelector('.nav.issue_actions a').click();
console.log('Opening gear menu');
await sleep();
// Get Rank to Top element
const rankToTopEl = Array.from(
document.querySelectorAll('.ajs-layer.active .aui-last a')
).find(el => el.textContent.trim() === 'Rank to Top');
if (rankToTopEl) {
console.log('Clicking Rank to Top');
if (!dryRun) {
rankToTopEl.click();
}
await sleep();
}
console.groupEnd(message);
}
console.log('Done!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment