final Set<Sponsor> sponsors = new HashSet<Sponsor>();
final List<RunningBuild> runningBuilds = new ArrayList<RunningBuild>();
long startTime = 0L;
for(Build build : communicator.runningBuildsFor(buildType)) {
final BuildDetail buildDetail = communicator.detailsOf(build);
startTime = Math.max(buildDetail.startDateTime(), startTime);
sponsors.addAll(sponsorsOf(buildDetail));
runningBuilds.add(new RunningBuild(percentageOf(build.percentageComplete), buildDetail.status()));
}
Status currentStatus = Status.UNKNOWN;
final Build lastCompletedBuild = communicator.lastCompletedBuildFor(buildTypeDetail);
if (null != lastCompletedBuild) {
currentStatus = lastCompletedBuild.status();
if (runningBuilds.isEmpty() || Status.BROKEN.equals(currentStatus)) {
final BuildDetail buildDetail = communicator.detailsOf(lastCompletedBuild);
startTime = Math.max(buildDetail.startDateTime(), startTime);
sponsors.addAll(sponsorsOf(buildDetail));
currentStatus = buildDetail.status();
}
}
if (Status.BROKEN.equals(currentStatus)) {
final List<Investigation> investigations = communicator.investigationsOf(buildType);