diff --git a/owlcms/src/main/java/app/owlcms/data/group/Group.java b/owlcms/src/main/java/app/owlcms/data/group/Group.java index 23f782afd..f568dd8c0 100644 --- a/owlcms/src/main/java/app/owlcms/data/group/Group.java +++ b/owlcms/src/main/java/app/owlcms/data/group/Group.java @@ -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 { + + 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 c = new NaturalOrderComparator<>();