Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Sort by percent approved as double, not int
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Oct 3, 2013
1 parent 29d10f4 commit 535b2e7
Showing 1 changed file with 10 additions and 9 deletions.
Expand Up @@ -162,15 +162,16 @@ public Status(String locale, String nativeName,

@Override
public int compareTo(Status o) {
int per =
getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0
* getStats().getApproved() / getStats().getTotal());
int comparePer =
o.getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0
* o.getStats().getApproved()
/ o.getStats().getTotal());

return Double.compare(comparePer, per);
// TODO compare by locale too?
// TODO if totals are the same, we only need to compare approved
return Double.compare(o.getPercentApproved(), getPercentApproved());
}

private double getPercentApproved() {
// TODO move to TranslationStatistics.getPercentApproved() ?
long total = getStats().getTotal();
long approved = getStats().getApproved();
return total == 0 ? 0 : 100d * approved / total;
}
}

Expand Down

0 comments on commit 535b2e7

Please sign in to comment.