Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,23 @@ private[v1] class ApplicationListResource(uiRoot: UIRoot) {
status
}
}

val numApps = Option(limit).map(_.toInt).getOrElse(Integer.MAX_VALUE)
val includeCompleted = adjStatus.contains(ApplicationStatus.COMPLETED)
val includeRunning = adjStatus.contains(ApplicationStatus.RUNNING)
val appList = allApps.filter { app =>
allApps.filter { app =>
val anyRunning = app.attempts.exists(!_.completed)
// if any attempt is still running, we consider the app to also still be running
val statusOk = (!anyRunning && includeCompleted) ||
(anyRunning && includeRunning)

// keep the app if *any* attempts fall in the right time window
val dateOk = app.attempts.exists { attempt =>
attempt.startTime.getTime >= minDate.timestamp &&
attempt.startTime.getTime <= maxDate.timestamp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be off topic but if your original concern was performance, then I'd note that there's no real need to evaluate dateOk by looking at all attempts again, if statusOk is false. Not sure it matters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Compared to the transformation from ApplicationHistoryInfo to ApplicationInfo, this one is negligible.

}
statusOk && dateOk
}
if (limit != null) {
appList.take(limit)
} else {
appList
}
}.take(numApps)
}
}

Expand Down