Fix registration page and display MMS of preliminary players
This commit is contained in:
@@ -20,7 +20,7 @@ import kotlin.math.roundToInt
|
||||
|
||||
// TODO CB avoid code redundancy with solvers
|
||||
|
||||
fun Tournament<*>.getSortedPairables(round: Int): List<Json.Object> {
|
||||
fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = false): List<Json.Object> {
|
||||
|
||||
fun Pairable.mmBase(): Double {
|
||||
if (pairing !is MacMahon) throw Error("invalid call: tournament is not Mac Mahon")
|
||||
@@ -66,6 +66,7 @@ fun Tournament<*>.getSortedPairables(round: Int): List<Json.Object> {
|
||||
val neededCriteria = ArrayList(pairing.placementParams.criteria)
|
||||
if (!neededCriteria.contains(Criterion.NBW)) neededCriteria.add(Criterion.NBW)
|
||||
if (!neededCriteria.contains(Criterion.RATING)) neededCriteria.add(Criterion.RATING)
|
||||
if (type == Tournament.Type.INDIVIDUAL && pairing.type == PairingType.MAC_MAHON && !neededCriteria.contains(Criterion.MMS)) neededCriteria.add(Criterion.MMS)
|
||||
val criteria = neededCriteria.map { crit ->
|
||||
crit.name to when (crit) {
|
||||
Criterion.NONE -> StandingsHandler.nullMap
|
||||
@@ -100,7 +101,7 @@ fun Tournament<*>.getSortedPairables(round: Int): List<Json.Object> {
|
||||
Criterion.DC -> StandingsHandler.nullMap
|
||||
}
|
||||
}
|
||||
val pairables = pairables.values.filter { it.final }.map { it.toDetailedJson() }
|
||||
val pairables = pairables.values.filter { includePreliminary || it.final }.map { it.toDetailedJson() }
|
||||
pairables.forEach { player ->
|
||||
for (crit in criteria) {
|
||||
player[crit.first] = (crit.second[player.getID()] ?: 0.0).toInt()
|
||||
|
@@ -32,8 +32,9 @@ object StandingsHandler: PairgothApiHandler {
|
||||
override fun get(request: HttpServletRequest, response: HttpServletResponse): Json? {
|
||||
val tournament = getTournament(request)
|
||||
val round = getSubSelector(request)?.toIntOrNull() ?: ApiHandler.badRequest("invalid round number")
|
||||
val includePreliminary = request.getParameter("include_preliminary")?.let { it.toBoolean() } ?: false
|
||||
|
||||
val sortedPairables = tournament.getSortedPairables(round)
|
||||
val sortedPairables = tournament.getSortedPairables(round, includePreliminary)
|
||||
val sortedMap = sortedPairables.associateBy {
|
||||
it.getID()!!
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
## Team players do not have an individual MMS
|
||||
#if($tour.type == 'INDIVIDUAL' && $tour.pairing.type == 'MAC_MAHON')
|
||||
#set($mmbase = $api.get("tour/${params.id}/standings/0"))
|
||||
#set($mmbase = $api.get("tour/${params.id}/standings/0?include_preliminary=true"))
|
||||
#if($mmbase.isObject() && ($mmbase.error || $mmbase.message))
|
||||
#if($mmbase.error)
|
||||
#set($error = $mmbase.error)
|
||||
@@ -86,7 +86,7 @@
|
||||
<td data-sort="$part.rank">#rank($part.rank)#if($part.mmsCorrection)<span class="noprint"> (#if($part.mmsCorrection > 0)+#end$part.mmsCorrection)</span>#end</td>
|
||||
<td>$part.rating</td>
|
||||
#if($tour.type == 'INDIVIDUAL' && $tour.pairing.type == 'MAC_MAHON')
|
||||
<td>$mmsPlayersMap[$part.id]</td>
|
||||
<td>$!mmsPlayersMap[$part.id]</td>
|
||||
#end
|
||||
<td class="participating" data-sort="#if($part.skip)$part.skip.size()/part.skip#{else}0#end">
|
||||
<div class="participation">
|
||||
|
Reference in New Issue
Block a user