Navigation Menu

Skip to content

Commit

Permalink
Revert "[JENKINS-37329] - Changed caluclation of RoundDecimal again."
Browse files Browse the repository at this point in the history
This reverts commit f22fe98.
  • Loading branch information
opx3 committed Aug 20, 2016
1 parent b4486c4 commit 8ace1d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Expand Up @@ -23,6 +23,7 @@ public class StatsFactory {
private int totalUnstable;
private int totalNobuild;
private int totalBuilds;
private String space;

public StatsFactory(){
this.stats = new Hashtable<String, StatsModel>();
Expand All @@ -32,6 +33,7 @@ public StatsFactory(){
this.totalUnstable = 0;
this.totalNobuild = 0;
this.totalBuilds = 0;
this.space="&nbsp;";
}

public static StatsFactory generateStats(List<JobBuildSearchResult> searchResults){
Expand Down Expand Up @@ -166,4 +168,10 @@ public int getTotalBuilds(){
public double getFailureRate(){
return StatsMath.getPercent(this.totalBuilds - this.totalSuccess, this.totalBuilds);
}

@Exported
public String getPaddedFailureRate(){
return String.format("%12.2f", this.getFailureRate()).replace(" ", this.space);
}

}
Expand Up @@ -11,8 +11,8 @@ public static double getPercent(double subVal, double totalVal){
}

public static double roundTwoDecimals(double iVal){
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.getDefault());
DecimalFormat twoDForm = new DecimalFormat("#"+decimalFormatSymbols.getDecimalSeparator()+"##",decimalFormatSymbols);
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH);
DecimalFormat twoDForm = new DecimalFormat("#.00",decimalFormatSymbols);
return Double.valueOf(twoDForm.format(iVal));
}
}
Expand Up @@ -11,7 +11,8 @@ public class StatsModel implements Comparable{
private int aborts;
private int unstables;
private int nobuilds;
private int totalBuilds;
private int totalBuilds;
private String space;

public StatsModel(String jobName){
this.jobName = jobName;
Expand All @@ -21,6 +22,7 @@ public StatsModel(String jobName){
this.unstables = 0;
this.nobuilds = 0;
this.totalBuilds = 0;
this.space="&nbsp;";
}

public String getJobName(){
Expand Down Expand Up @@ -86,6 +88,11 @@ public int getTotalBuilds(){
public double getFailureRate(){
return StatsMath.getPercent(this.totalBuilds - this.successes, this.totalBuilds);
}

@Exported
public String getPaddedFailureRate(){
return String.format("%12.2f", this.getFailureRate()).replace(" ", this.space);
}

public int compareTo(Object o){
if(o instanceof StatsModel) return compareTo((StatsModel)o);
Expand Down
Expand Up @@ -40,7 +40,7 @@
<td class="pane">${stat.aborts}</td>
<td class="pane">${stat.noBuilds}</td>
<td class="pane">${stat.totalBuilds}</td>
<td class="pane">${stat.failureRate}%</td>
<td class="pane">${stat.paddedFailureRate}%</td>
</tr>
</j:forEach>
<tr>
Expand All @@ -51,7 +51,7 @@
<th class="pane" style="font-weight:bold;">${buildStats.aborts}</th>
<th class="pane" style="font-weight:bold;">${buildStats.noBuilds}</th>
<th class="pane" style="font-weight:bold;">${buildStats.totalBuilds}</th>
<th class="pane" style="font-weight:bold;">${buildStats.failureRate}%</th>
<th class="pane" style="font-weight:bold;">${buildStats.paddedFailureRate}%</th>
</tr>
</table>
</j:otherwise>
Expand Down

0 comments on commit 8ace1d0

Please sign in to comment.