diff options
Diffstat (limited to 'pages/score.inc')
-rw-r--r-- | pages/score.inc | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/pages/score.inc b/pages/score.inc new file mode 100644 index 0000000..e04f9e7 --- /dev/null +++ b/pages/score.inc @@ -0,0 +1,208 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h2>Score system testing</h2> + + <h4>Raindrops System (<code><?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = $score["total"]; + } + } + + $total = array_reduce($scores, function($a, $b) { + return $a + $b; + }); + + echo round($total / (count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true)) - 1)); + + ?></code>)</h4> + <ul> + <?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + $name = $member["display_name"] ?? $member["name"]; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = [ + "name" => $name, + "page" => "/" . $member["name"], + "score" => $score["total"], + "details" => $score + ]; + } + } + + uasort($scores, function($a, $b) { + return $b["score"] - $a["score"]; + }); + + ?> + + <?php foreach ($scores as $score): ?> + <li> + <details> + <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary> + <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre> + </details> + </li> + <?php endforeach; ?> + </ul> + + + <h4>Cloudburst System (<code><?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = $score["total"]; + } + } + + $total = array_reduce($scores, function($a, $b) { + return $a + $b; + }); + + echo round($total / (count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true)) - 1)); + + ?></code>)</h4> + <ul> + <?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + $name = $member["display_name"] ?? $member["name"]; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = [ + "name" => $name, + "page" => "/" . $member["name"], + "score" => $score["total"], + "details" => $score + ]; + } + } + + uasort($scores, function($a, $b) { + return $b["score"] - $a["score"]; + }); + + ?> + + <?php foreach ($scores as $score): ?> + <li> + <details> + <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary> + <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre> + </details> + </li> + <?php endforeach; ?> + </ul> + + <h4>Global (<code><?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = $score["total"]; + } + } + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = $score["total"]; + } + } + + $total = array_reduce($scores, function($a, $b) { + return $a + $b; + }); + + echo round($total / ((count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true)) + count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true))) - 2)); + + ?></code>)</h4> + <ul> + <?php + + $scores = []; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + $name = $member["display_name"] ?? $member["name"]; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = [ + "name" => $name, + "page" => "/" . $member["name"], + "score" => $score["total"], + "details" => $score + ]; + } + } + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_ends_with($member["name"], "-travelling")) { + $name = $member["display_name"] ?? $member["name"]; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); + $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); + + $scores[] = [ + "name" => $name, + "page" => "/" . $member["name"], + "score" => $score["total"], + "details" => $score + ]; + } + } + + uasort($scores, function($a, $b) { + return $b["score"] - $a["score"]; + }); + + ?> + + <?php foreach ($scores as $score): ?> + <li> + <details> + <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary> + <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre> + </details> + </li> + <?php endforeach; ?> + </ul> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?> |