Bind league fixtures and round navigation to live engine data (by Codex)
This commit is contained in:
1 parent
1c35698dbe
commit
545e16f153
21 files changed
+207
-31
No files matched your search
@@ -487,6 +487,21 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
|
||||
A leagues;for(int l=0;l<kLeagueCount;++l)leagues.push_back(report_league(g,l,team_of(g,c.manager)));
|
||||
return snapshot(request_id,std::move(m),O{{"kind","report-index"},{"leagues",std::move(leagues)}});
|
||||
}
|
||||
if(kind=="league-fixtures") {
|
||||
const std::string id=text_field(request,"leagueId");int league=-1;
|
||||
for(int l=0;l<kLeagueCount;++l)if(*std::get<O>(report_league(g,l,-1).value).at("id").string()==id){league=l;break;}
|
||||
const auto* round=field(request,"round");
|
||||
if(league<0||(round&&(!round->integer()||*round->integer()<1||*round->integer()>league_matchdays(league))))
|
||||
return failure(request_id,"invalid_fixture_request","Liga oder Spieltag ist nicht verfügbar.",c.state_revision);
|
||||
O query{{"kind","fixtures"},{"league",id}};
|
||||
if(round)query["matchday"]=*round;
|
||||
J data=query_projection(g,c.manager,query);
|
||||
auto* values=std::get_if<O>(&data.value);
|
||||
if(!values||!values->count("ok")||!std::holds_alternative<bool>(values->at("ok").value)||!std::get<bool>(values->at("ok").value))
|
||||
return failure(request_id,"fixtures_unavailable","Die Paarungen sind derzeit nicht verfügbar.",c.state_revision);
|
||||
values->erase("ok");(*values)["kind"]="league-fixtures";(*values)["leagueId"]=id;(*values)["round"]=values->at("matchday");(*values)["rounds"]=league_matchdays(league);
|
||||
return snapshot(request_id,std::move(m),std::move(data));
|
||||
}
|
||||
if(kind=="league-report") {
|
||||
const std::string id=text_field(request,"leagueId");int league=-1;
|
||||
for(int l=0;l<kLeagueCount;++l)if(*std::get<O>(report_league(g,l,-1).value).at("id").string()==id){league=l;break;}
|
||||
|
||||
Reference in new issue
Block a user