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

+16 -5
View File
@@ -121,8 +121,9 @@ Json report(const Json &fixture, const Json &match, int minute) {
// no player actor, assist or exact playing-time/ratings, so none is inferred.
out["events"] = match_events(frame->at("events"), match.at("id"));
out["timeline"] = match_events(frames.back().at("events"), match.at("id"));
out["attendance"] = nullptr;
out["attendance_reason"] = "not_recorded";
out["attendance"] = match.value("attendance", Json());
out["attendance_reason"] = out["attendance"].is_null() ? "not_recorded" : "recorded";
out["weather"] = match.value("weather", Json());
out["actor"] = nullptr; out["assists"] = nullptr; out["ratings"] = nullptr;
out["playing_minutes"] = nullptr;
return out;
@@ -145,14 +146,19 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const
out["matches"] = Json::array(); out["tables"] = Json::array();
Json totals = {{"games", fixture.at("matches").size()}, {"goals", 0},
{"yellow", 0}, {"red", 0}, {"chances", 0},
{"attendance", nullptr}, {"attendance_reason", "not_recorded"},
{"attendance", int64_t(0)}, {"attendance_reason", "recorded"},
{"scope", "recorded_human_matches"}};
bool crowds_known = true;
for (const auto &match : fixture.at("matches")) {
const auto &final = match_snapshot(last, match.at("id"));
auto row = match;
row["final"] = final;
row["events"] = match_events(last.at("events"), match.at("id"));
row["attendance"] = nullptr; row["attendance_reason"] = "not_recorded";
row["attendance"] = match.value("attendance", Json());
row["attendance_reason"] = row["attendance"].is_null() ? "not_recorded" : "recorded";
row["weather"] = match.value("weather", Json());
if (row["attendance"].is_null()) crowds_known = false;
else totals["attendance"] = totals.at("attendance").get<int64_t>() + row.at("attendance").get<int64_t>();
out["matches"].push_back(std::move(row));
for (auto key : {"yellow", "red", "chances"})
totals[key] = totals.at(key).get<int>() + final.at(key)[0].get<int>() + final.at(key)[1].get<int>();
@@ -170,9 +176,14 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const
{"wins", nullptr}, {"draws", nullptr}, {"losses", nullptr}});
}
}
if (!crowds_known) {
totals["attendance"] = nullptr;
totals["attendance_reason"] = "not_recorded";
}
out["overview"] = std::move(totals);
out["eleven"] = {{"available", false}, {"reason", "not_recorded"}, {"rows", Json::array()}};
out["unknown_fields"] = Json::array({"attendance", "actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"});
out["unknown_fields"] = Json::array({"actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"});
if (!crowds_known) out["unknown_fields"].push_back("attendance");
if (const auto *error = attach_records(out, fixture, records)) return failure(error);
return out;
} catch (const std::exception &) { return failure("invalid_post_match_fixture"); }