From a1a37631b33ae3d2022f46858467e7a001baa012 Mon Sep 17 00:00:00 2001 From: Ugo Finnendahl Date: Sun, 3 Nov 2024 15:17:22 +0100 Subject: [PATCH] bug fixes for double in --- assets/js/views/xoi/main.js | 11 ++++++++--- site/models/xoi.php | 28 +++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/assets/js/views/xoi/main.js b/assets/js/views/xoi/main.js index 305573a..b5a3481 100644 --- a/assets/js/views/xoi/main.js +++ b/assets/js/views/xoi/main.js @@ -54,7 +54,7 @@ const pregame = {
Player 1:
Player 2:
X01:
-
Out:
+
In:
Best of Legs (per Set):
@@ -127,8 +127,7 @@ const player = { props: ['page', 'id', 'current_stat'], setup(props) { const addStats = (stat1, stat2) => { - console.log(stat1); - return { + let res = { average: [stat1.average[0]+stat2.average[0], stat1.average[1]+stat2.average[1]], first9: [stat1.first9[0]+stat2.first9[0], stat1.first9[1]+stat2.first9[1]], "60+": stat1["60+"]+stat2["60+"], @@ -138,6 +137,12 @@ const player = { "checkouts": [stat1.checkouts[0]+stat2.checkouts[0], stat1.checkouts[1]+stat2.checkouts[1]], "checkoutPoints": [...stat1.checkoutPoints, ...stat2.checkoutPoints] } + if ("checkins" in stat1 && "checkins" in stat2){ + res["checkins"] = [stat1.checkins[0]+stat2.checkins[0], stat1.checkins[1]+stat2.checkins[1]]; + res["checkinPoints"] = [...stat1.checkinPoints, ...stat2.checkinPoints]; + } + + return res; } const inspect = !!props.page.enddate; const tourStats = computed(() => { diff --git a/site/models/xoi.php b/site/models/xoi.php index 3498680..d42bc65 100644 --- a/site/models/xoi.php +++ b/site/models/xoi.php @@ -16,25 +16,27 @@ class XoiPage extends Page { $sum["checkouts"][0] += $stat2["checkouts"][0]; $sum["checkoutPoints"] = array_merge($sum["checkoutPoints"], $stat2["checkoutPoints"]); $sum["checkouts"][1] += $stat2["checkouts"][1]; - $sum["checkins"][0] += $stat2["checkins"][0]; - $sum["checkinPoints"] = array_merge($sum["checkinPoints"], $stat2["checkinPoints"]); - $sum["checkins"][1] += $stat2["checkins"][1]; + if (array_key_exists("checkins", $stat1) && array_key_exists("checkins", $stat2)){ + $sum["checkins"][0] += $stat2["checkins"][0]; + $sum["checkinPoints"] = array_merge($sum["checkinPoints"], $stat2["checkinPoints"]); + $sum["checkins"][1] += $stat2["checkins"][1]; + } $sum["180"] += $stat2["180"]; $sum["140+"] += $stat2["140+"]; $sum["100+"] += $stat2["100+"]; $sum["60+"] += $stat2["60+"]; return $sum; } - // - // /** - // * @kql-allowed - // */ - // public function tournamentStats() { - // if (count($this->playerUUIDs()) == 2){ - // return [$this->parent()->getStats($this->playerUUIDs()[0]),$this->parent()->getStats($this->playerUUIDs()[1])]; - // } - // return []; - // } + + /** + * @kql-allowed + */ + public function tournamentStats() { + if (count($this->playerUUIDs()) == 2){ + return [$this->parent()->getStats($this->playerUUIDs()[0]),$this->parent()->getStats($this->playerUUIDs()[1])]; + } + return []; + } // // public function reorderPlayer($order){ // kirby()->impersonate('kirby');