Skip to content

Commit

Permalink
optimize Job Statistics portlet
Browse files Browse the repository at this point in the history
Loading every build for every job can be expensive, especially in
pathologically cases with > 10k builds per job.  Fortunately the
portlet only needs to know that a non-zero number of builds exist and
not any of their details.

Problem diagnosed and fix approach proposed by Matthew Sawin

[FIXED JENKINS-26879]
  • Loading branch information
cburroughs committed Aug 6, 2015
1 parent d3862e1 commit 4eff12f
Showing 1 changed file with 1 addition and 2 deletions.
Expand Up @@ -51,7 +51,6 @@ public enum HealthStatus {

public static HealthStatus getHealthStatus(Job job) {
int score = job.getBuildHealth().getScore();
int nBuilds = job.getBuilds().size();
if (score < 20) {
return HEALTH_0_TO_19;
}
Expand All @@ -65,7 +64,7 @@ public static HealthStatus getHealthStatus(Job job) {
return HEALTH_60_TO_79;
}

return nBuilds != 0 ? HEALTH_OVER_80 : HEALTH_UNKNOWN;
return job.getFirstBuild() != null ? HEALTH_OVER_80 : HEALTH_UNKNOWN;
}

public String getIconUrl() {
Expand Down

0 comments on commit 4eff12f

Please sign in to comment.