summaryrefslogtreecommitdiff
path: root/pages/score.inc
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
committerMinteck <contact@minteck.org>2022-10-10 20:51:39 +0200
commit108525534c28013cfe1897c30e4565f9893f3766 (patch)
treedd3e5132971f96ab5f05e7f3f8f6dbbf379a19bd /pages/score.inc
parent2162eaa06f7e4764eb3dcfe130ec2c711d0c62ab (diff)
downloadpluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.gz
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.tar.bz2
pluralconnect-108525534c28013cfe1897c30e4565f9893f3766.zip
Update
Diffstat (limited to 'pages/score.inc')
-rw-r--r--pages/score.inc208
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'; ?>