Show attendance and weather before live ticker kickoff (by Codex)

This commit is contained in:
Codex committed 2026-10-27 10:59:45 +01:00
1 parent ef25407484
commit b845bbfcbc
10 files changed
+144 -14

No files matched your search

+22
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_live.hpp"
#include "modern/ui/live_match_info.hpp"
#include "modern/ui/demo_career.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/model.hpp"
@@ -111,6 +112,27 @@ int main(int argc, char **argv) {
Json{{"fixture_id", "wrong"}}}))
require(!query_demo_live(*f.world, initial.state, initial.revision, query).at("ok"), "unsupported/stale request rejected");
require(live_match_info_text(live.at("matches")[0], false) == "26.400 Zuschauer · 18 °C · sonnig",
"pre-match metadata is available before revealing any event");
auto old_recording = live;
for (auto &match : old_recording["matches"]) { match.erase("attendance"); match.erase("weather"); }
require(valid_live_fixture(old_recording) && live_match_info_text(old_recording.at("matches")[0], false) ==
"Zuschauer — · Wetter —", "old recordings remain valid without invented metadata");
const Json zero = {{"attendance", 0}, {"weather", {{"temperature", 0}, {"rain", 4}}}};
require(live_match_info_text(zero, false) == "0 Zuschauer · 0 °C · Regen", "known zero crowd and temperature are not missing");
require(live_match_info_text({{"attendance", 1200}, {"weather", {{"temperature", -3}, {"rain", 6}}}}, false) ==
"1.200 Zuschauer · -3 °C · Schnee", "signed temperature and original weather pictogram codes");
require(live_match_info_text(zero, true) == "0 Zuschauer · Halle", "indoor ignores outdoor weather");
for (const auto &bad : Json::array({Json{{"attendance", -1}}, Json{{"attendance", "1000"}},
Json{{"weather", "sun"}}, Json{{"weather", {{"rain", 8}}}},
Json{{"weather", {{"temperature", 128}}}},
Json{{"weather", {{"temperature", UINT64_MAX}}}}})) {
auto malformed = live; malformed["matches"][0].update(bad);
require(!valid_live_fixture(malformed), "malformed optional metadata rejects without changing playback");
}
require(source.snapshot().state == initial.state && source.snapshot().revision == initial.revision &&
source.dirty() == dirty, "formatting pre-match information is read-only");
LivePlayback playback;
require(playback.open(live, "manager:0"), "recording opens paused");
require(playback.sequence() == 0 && playback.speed() == 0 && !playback.elapse(100000),
+12 -3
View File
@@ -93,19 +93,28 @@ int main(int argc, char **argv) {
review.at("overview").at("chances") == 28 &&
review.at("overview").at("scope") == "recorded_human_matches",
"overview aggregates final recorded matches once, not once per human or whole league");
require(review.at("overview").at("attendance").is_null() &&
require(review.at("overview").at("attendance") == 57550 &&
!review.at("eleven").at("available").get<bool>() && review.at("eleven").at("reason") == "not_recorded" &&
review.at("eleven").at("rows").empty(), "unrecorded crowd and nominations stay unknown");
review.at("eleven").at("rows").empty(), "crowds counted once per match while unrecorded nominations stay unknown");
require(review.at("tables").size() == 1 && review.at("tables")[0].at("match_ids").size() == 2 &&
review.at("tables")[0].at("rows") == recording.at("frames").back().at("matches")[0].at("standings") &&
review.at("tables")[0].at("wins").is_null(), "shared final table is copied verbatim without season formula");
for (size_t i = 0; i < review.at("matches").size(); ++i) {
const auto &row = review.at("matches")[i];
require(row.at("final") == recording.at("frames").back().at("matches")[i] &&
row.at("id") == recording.at("matches")[i].at("id") && row.at("attendance").is_null(),
row.at("id") == recording.at("matches")[i].at("id") &&
row.at("attendance") == recording.at("matches")[i].at("attendance") &&
row.at("weather") == recording.at("matches")[i].at("weather"),
"result fields and identities equal exact final snapshot");
for (const auto &event : row.at("events")) require(event.at("match_id") == row.at("id"), "events cannot leak from another match");
}
auto old_recording = recording;
for (auto &match : old_recording["matches"]) { match.erase("attendance"); match.erase("weather"); }
const auto old_review = make_demo_post_match(old_recording, 8);
require(old_review.at("overview").at("attendance").is_null() &&
old_review.at("matches")[0].at("attendance").is_null() &&
old_review.at("matches")[0].at("weather").is_null(),
"old recordings still keep unrecorded crowds and weather unknown");
require(source.read_post_match(request(recording)) == review, "DemoSource read hook gives pure final review");
Json supplied = {{"schema", "openbmh-post-match-records@1"},
{"fixture_id", recording.at("fixture_id")},