Modern UI contract: press events from the almanac
The news read lists a team's press events derived from the almanac, so they are the same on every read with stable occurrence ids: match and cup results (final, extra time, penalties), send-offs and injuries, runs, league position, champion and titles, with typed facts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d943494ef4
commit
9c436c753e
5 files changed
+173
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include "game/state.hpp"
|
||||
#include "game/table.hpp"
|
||||
#include "modern/content/projections.hpp"
|
||||
#include "modern/content/statistics.hpp"
|
||||
#include "modern/content/world_package.hpp"
|
||||
#include "modern/game/almanac.hpp"
|
||||
#include "modern/game/desk_actions.hpp"
|
||||
@@ -370,6 +371,24 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
|
||||
if (kind == "session") return snapshot(request_id, std::move(m), session_data(g, c));
|
||||
if (kind == "desktop") return snapshot(request_id, std::move(m), desktop_data(g, c, today));
|
||||
if (kind == "camps") return snapshot(request_id, std::move(m), camps_data(g, c, std::to_string(c.state_revision)));
|
||||
if (kind == "news") {
|
||||
// the press events of a team (teamId, default the desk's team) from `from` to `until` (ISO,
|
||||
// default everything up to today), newest last, at most `limit` (default 50) of the newest
|
||||
const int team = requested_team(g, c, request);
|
||||
if (team < 0) return failure(request_id, "unknown_team", "teamId nennt kein Team.", c.state_revision);
|
||||
const std::string from = text_field(request, "from").empty() ? "0000-00-00" : text_field(request, "from");
|
||||
const std::string until = text_field(request, "until").empty() ? today : text_field(request, "until");
|
||||
const J* limit_field = field(request, "limit");
|
||||
const int64_t limit = limit_field && limit_field->integer() && *limit_field->integer() > 0 ? *limit_field->integer() : 50;
|
||||
J news = query_news(g, team_id(g, team), from, until);
|
||||
A events = std::move(std::get<A>(std::get<O>(news.value).at("events").value));
|
||||
const size_t total = events.size();
|
||||
if (events.size() > size_t(limit)) events.erase(events.begin(), events.end() - limit);
|
||||
return snapshot(request_id, std::move(m),
|
||||
O{{"kind", "news"}, {"teamId", team_id(g, team)}, {"from", from}, {"until", until}, {"total", int64_t(total)},
|
||||
{"events", std::move(events)},
|
||||
{"source", "almanac"}, {"note", "Spielereignisse, Serien und Saisonabschlüsse; Geschäftsereignisse folgen"}});
|
||||
}
|
||||
if (kind == "calendar") {
|
||||
// the season calendar of the desk's team: days from `from` to `until` (ISO dates, default
|
||||
// the current month) with the day's competitions and the team's league matches (planned
|
||||
|
||||
Reference in new issue
Block a user