Skip to content

Commit

Permalink
added group range
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Aug 21, 2024
1 parent ca1e059 commit aed0dd3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions owlcms/src/main/java/app/owlcms/data/group/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = Group.class)
@JsonIgnoreProperties(ignoreUnknown = true, value = { "hibernateLazyInitializer", "logger", "athletes" })
public class Group implements Comparable<Group> {

public record Range (Integer min, Integer max) {
public String getFormattedRange() {
if (min == Integer.MAX_VALUE && max == 0) {
return "";
} else if (min == max) {
return min.toString();
} else {
return min.toString()+" - "+max.toString();
}
}
};

@Transient
@JsonIgnore
public Range getStartingRange() {
int min = Integer.MAX_VALUE;
int max = 0;
for (Athlete a : getAthletes()) {
Integer q = a.getQualifyingTotal();
if (q == null) {
continue;
}
min = q < min ? q : min;
max = q > max ? q : max;
}
return new Range(min, max);
}

private final static Logger logger = (Logger) LoggerFactory.getLogger(Group.class);
private final static NaturalOrderComparator<String> c = new NaturalOrderComparator<>();
Expand Down

0 comments on commit aed0dd3

Please sign in to comment.