Get the sprints which are having only closed issues based on the sprint start date

Bhargavi Vasa
Contributor
March 20, 2023

Able to fetch the sprint details which are having only closed issues for the given date(sprint details and issues under it) but getting other sprint details as well with no issues for the below code

Can someone help me to modify this code to skip the unwanted sprints which do not have the issues and print only the sprints based on the conditions

 

string format = "MM/dd/yyyy"; //format for date
string creationdate = currentDate()-"90d";
runnerLog("creation date: " + creationdate);
for(JSprint sprint in getAllOpenSprints()) {
if (sprint.startDate < creationdate && sprint.state =="ACTIVE") {

string [] keys =selectIssues("Sprint = '" +sprint.name+ "'");

Boolean allClosed =true;

for(string key in keys) {

if(key.status!="Closed"){

all closed=false;

break;

}

}

if(allClosed){

runnerLog("Sprint name: " + sprint.name);
runnerLog("Sprint id: " + sprint.id);
runnerLog("Sprint start date: " +formatDate(sprint.startDate, format));
runnerLog("Sprint state: " +sprint.state);
runnerLog(keys);

updateSprint(sprint.id, sprint.name, "Closed" );
runnerLog("Sprint was updated: " + sprint.name );
}
}

}

1 answer

1 accepted

0 votes
Answer accepted
Bhargavi Vasa
Contributor
March 21, 2023

string format = "MM/dd/yyyy"; //format for date

string creationdate = currentDate()-"90d";

runnerLog("creation date: " + creationdate);

for(JSprint sprint in getAllOpenSprints()) {

if (sprint.startDate < creationdate && sprint.state =="ACTIVE") {

string [] keys =selectIssues("Sprint = '" +sprint.name+ "'");

if(length(key)==0){

continue;

}

Boolean allClosed =true;

for(string key in keys) {

if(key.status!="Closed"){

all closed=false;

break;

}

}

if(allClosed){

runnerLog("Sprint name: " + sprint.name);

runnerLog("Sprint id: " + sprint.id);

runnerLog("Sprint start date: " +formatDate(sprint.startDate, format));

runnerLog("Sprint state: " +sprint.state);

runnerLog(keys);

updateSprint(sprint.id, sprint.name, "Closed" );

runnerLog("Sprint was updated: " + sprint.name );

}

}

}

Suggest an answer

Log in or Sign up to answer