diff --git a/html/index.php b/html/index.php index a76c429..eebfd6a 100644 --- a/html/index.php +++ b/html/index.php @@ -15,7 +15,7 @@ function renderChoice(): void { if ($ajax) { include __DIR__ . "/../view/fragments/mobSelection.php"; } else { - $title = "Test"; + $title = "MobMash"; $content = function() use ($left, $right, $csrfToken) { include __DIR__ . "/../view/pages/mobSelection.php"; }; diff --git a/html/results/index.php b/html/results/index.php new file mode 100644 index 0000000..0b8942c --- /dev/null +++ b/html/results/index.php @@ -0,0 +1,13 @@ +prepare("INSERT INTO mm_matches (mob1fk, mob2fk, winner, session) VALUES (?, ?, ?, ?)"); $query->execute([$mob1, $mob2, $winner, $session]); +} + +function getMobsWithMetaData($orderBy = "rating", $direction = "DESC"): array { + global $pdo; + $query = $pdo->prepare(<<execute(); + return $query->fetchAll(PDO::FETCH_ASSOC); } \ No newline at end of file diff --git a/migrations/0001_mobsMatchesAndRating.sql b/migrations/0001_mobsMatchesAndRating.sql index be72bf3..cfee350 100644 --- a/migrations/0001_mobsMatchesAndRating.sql +++ b/migrations/0001_mobsMatchesAndRating.sql @@ -170,4 +170,34 @@ FROM jsonb_each( FROM mm_rating_history ) ) -); \ No newline at end of file +); + +CREATE VIEW mm_rating_trends (mob, rating, "date", id) AS +SELECT + key AS mob, + value AS rating, + "date", + id +FROM ( + SELECT + id, + ratings, + "date" + FROM ( + SELECT + max(id) AS id, + "date" + FROM ( + SELECT + last_update AS id, + date(matches.created) AS "date" + FROM mm_history_cache AS history + INNER JOIN mm_matches AS matches + ON history.last_update = matches.id + ) AS dates + GROUP BY "date" + ) AS key_dates + INNER JOIN mm_history_cache AS history + ON key_dates.id = history.last_update +) AS ratings_at_key_date, +jsonb_each(ratings_at_key_date.ratings) AS ratings(key, value); diff --git a/view/fragments/mobList.php b/view/fragments/mobList.php new file mode 100644 index 0000000..cd6428c --- /dev/null +++ b/view/fragments/mobList.php @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + +
+ Position + + + + Name + + Rating + + Matches + + Wins + + Losses + + Trend +
diff --git a/view/fragments/mobListItem.php b/view/fragments/mobListItem.php new file mode 100644 index 0000000..eca711d --- /dev/null +++ b/view/fragments/mobListItem.php @@ -0,0 +1,26 @@ + + + + + + + " /> + + + + + + + + + + + + + + + + + diff --git a/view/pages/results.php b/view/pages/results.php new file mode 100644 index 0000000..7f9d502 --- /dev/null +++ b/view/pages/results.php @@ -0,0 +1,7 @@ + +

Results

+ \ No newline at end of file