From c70eb0127465ca9e6d71111c170a716f0947c738 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 00:20:50 +0200 Subject: [PATCH 1/7] index-ffg is only for oauth --- .../src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt index befb42c..05246a1 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt @@ -57,7 +57,7 @@ class AuthFilter: Filter { chain.doFilter(req, resp) } else { // TODO - protection against brute force attacks - if (uri.endsWith("/index")) { + if (uri.endsWith("/index") && auth == "oauth") { response.sendRedirect("/index-ffg") } else { response.sendRedirect("/login") From 8729f82ef4f56d98f03de29c6cf5b36d981f076a Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 10:24:50 +0200 Subject: [PATCH 2/7] 'sesame' is a password --- view-webapp/src/main/webapp/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view-webapp/src/main/webapp/login.html b/view-webapp/src/main/webapp/login.html index bed6087..78dc0c4 100644 --- a/view-webapp/src/main/webapp/login.html +++ b/view-webapp/src/main/webapp/login.html @@ -4,7 +4,7 @@
- +
 
From 13e878c0ce5a149edc304856f72eb5328e520b4d Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 10:57:50 +0200 Subject: [PATCH 3/7] Fix EGF rating => rank calculation --- .../org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt index bb6abbf..6422969 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt @@ -5,6 +5,8 @@ import java.net.URL import java.time.LocalDate import java.time.format.DateTimeFormatter import java.util.* +import kotlin.math.ceil +import kotlin.math.floor object EGFRatingsHandler: RatingsHandler(RatingsManager.Ratings.EGF) { val ratingsDateFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.ENGLISH) @@ -29,7 +31,10 @@ object EGFRatingsHandler: RatingsHandler(RatingsManager.Ratings.EGF) { player["origin"] = "EGF" // override rank with rating equivalent player["rating"]?.toString()?.toIntOrNull()?.let { rating -> - player["rank"] = ((rating - 2050)/100).let { if (it < 0) "${-it+1}k" else "${it+1}d" } + val rank = (rating - 2050.0) / 100.0 + player["rank"] = + if (rank < 0) "${-floor(rank).toInt()}k" + else "${ceil(rank + 0.00001).toInt()}d" } if ("UK" == player.getString("country")) { player["country"] = "GB" From bbf0308994ee3850103f79bebf1b16322c372a0e Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 11:45:54 +0200 Subject: [PATCH 4/7] Code cleanup --- .../org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt index 6422969..fafb97b 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/EGFRatingsHandler.kt @@ -31,10 +31,10 @@ object EGFRatingsHandler: RatingsHandler(RatingsManager.Ratings.EGF) { player["origin"] = "EGF" // override rank with rating equivalent player["rating"]?.toString()?.toIntOrNull()?.let { rating -> - val rank = (rating - 2050.0) / 100.0 + val adjusted = rating - 2050; player["rank"] = - if (rank < 0) "${-floor(rank).toInt()}k" - else "${ceil(rank + 0.00001).toInt()}d" + if (adjusted < 0) "${-(adjusted - 99) / 100}k" + else "${(adjusted + 100) / 100}d" } if ("UK" == player.getString("country")) { player["country"] = "GB" From d7952fcf9465a38025c2ecc7e4439e1a0f281025 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 11:58:28 +0200 Subject: [PATCH 5/7] MM/Swiss can only be chosen at tournament creation, and display according fields properly --- view-webapp/src/main/webapp/js/tour-information.inc.js | 8 ++++++++ view-webapp/src/main/webapp/tour-information.inc.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/view-webapp/src/main/webapp/js/tour-information.inc.js b/view-webapp/src/main/webapp/js/tour-information.inc.js index 1f43858..a009703 100644 --- a/view-webapp/src/main/webapp/js/tour-information.inc.js +++ b/view-webapp/src/main/webapp/js/tour-information.inc.js @@ -278,4 +278,12 @@ onLoad(() => { shortName.on('input', e => { manualShortName = true; }); + + $('select[name="pairing"]').on('change', e => { + let pairing = e.target.value.toLowerCase(); + if (pairing === 'mms') $('#tournament-infos .mms').removeClass('hidden'); + else $('#tournament-infos .mms').addClass('hidden'); + if (pairing === 'swiss') $('#tournament-infos .swiss').removeClass('hidden'); + else $('#tournament-infos .swiss').addClass('hidden'); + }); }); diff --git a/view-webapp/src/main/webapp/tour-information.inc.html b/view-webapp/src/main/webapp/tour-information.inc.html index b7a43aa..9571549 100644 --- a/view-webapp/src/main/webapp/tour-information.inc.html +++ b/view-webapp/src/main/webapp/tour-information.inc.html @@ -89,7 +89,7 @@
- ## TODO From 734727c2af5b339f5c4041ebdfc4b151640b2db2 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 13 Jul 2024 12:53:47 +0200 Subject: [PATCH 6/7] Do not count preliminary players in round stats --- .../src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt index 2ee8fa9..04551ec 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt @@ -143,7 +143,7 @@ sealed class Tournament ( fun stats() = (0..rounds - 1).map { index -> Json.Object( - "participants" to pairables.values.count { !it.skip.contains(index + 1) }, + "participants" to pairables.values.count { it.final && !it.skip.contains(index + 1) }, "paired" to (games.getOrNull(index)?.values?.flatMap { listOf(it.black, it.white) }?.count { it != 0 } ?: 0), "games" to (games.getOrNull(index)?.values?.count() ?: 0), "ready" to (games.getOrNull(index)?.values?.count { it.result != Game.Result.UNKNOWN } ?: 0) From 8cc53dc2eac215813572b7a3c0df5dd827814072 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Mon, 22 Jul 2024 12:38:51 +0200 Subject: [PATCH 7/7] Fix handling of BIP game in tables renumbering --- .../main/kotlin/org/jeudego/pairgoth/model/Tournament.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt index 04551ec..f1b0c5e 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt @@ -132,8 +132,10 @@ sealed class Tournament ( if (pivot != null && nextTable == pivot.table) { ++nextTable } - changed = changed || game.table != nextTable - game.table = nextTable++ + if (game.table != 0) { + changed = changed || game.table != nextTable + game.table = nextTable++ + } } return changed }