Bind player rankings and fair play to recorded season events (by Codex)

This commit is contained in:
Codex committed 2026-10-28 23:46:35 +01:00
1 parent 6b4aa9772d
commit 738ecc7a09
27 files changed
+436 -36

No files matched your search

+12
View File
@@ -387,6 +387,18 @@ int main() {
bad_other=other_read;bad_other["data"]["matches"][0]["result"]={1,2};rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
bad_other=other_read;bad_other["data"]["entry"]=1;rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
bad_other=other_read;bad_other["meta"]["stateRevision"]="42";rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
auto rankings_bundle=report_bundle;for(auto &r:rankings_bundle)r["meta"]["season"]={{"label","2026/27"}};
const auto rw=[&](const Json &d){return Json{{"messageType","snapshot"},{"meta",rankings_bundle.at("desktop").at("meta")},{"data",d}};};const auto ri=rw(report_index_data);
Json ranking_row={{"rank",1},{"player",{{"id","player:score"},{"name","Synthetic Scorer"}}},{"club",{{"id","club:6"},{"name","Live A"}}},{"goals",2},{"assists",1},{"yellow",0},{"red",0},{"second_yellow",0},{"appearances",3},{"value",2},{"photoAssetId",nullptr},{"currentTeam",{{"id","club:7"},{"name","Live B"}}}};
Json rc=Json::array({Json::array({ranking_row}),Json::array(),Json::array(),Json::array()});const auto rr=rw({{"kind","player-rankings"},{"requestLeagueId","league:live"},{"leagueId","league:live"},{"scope",0},{"season","2026/27"},{"team",{{"id","club:6"},{"name","Live A"}}},{"categories",rc}});
require(engine_rankings_projection(rankings_bundle,ri,rr,"league:live",0).at("categories")[0][0].at("player")=="player:score","ranked player identity lost");
auto archived_rank=rr;archived_rank["data"]["categories"][0][0]["currentTeam"]=nullptr;require(engine_rankings_projection(rankings_bundle,ri,archived_rank,"league:live",0).at("categories")[0][0].at("currentTeam").is_null(),"archived-only identity received a fake current team");
auto bad_rank=rr;bad_rank["data"]["categories"][0][0]["rank"]=2;rejects([&]{engine_rankings_projection(rankings_bundle,ri,bad_rank,"league:live",0);});
bad_rank=rr;bad_rank["data"]["categories"][0][0]["value"]=5;rejects([&]{engine_rankings_projection(rankings_bundle,ri,bad_rank,"league:live",0);});
bad_rank=rr;bad_rank["data"]["season"]="2025/26";rejects([&]{engine_rankings_projection(rankings_bundle,ri,bad_rank,"league:live",0);});
bad_rank=rr;bad_rank["meta"]["stateRevision"]="42";rejects([&]{engine_rankings_projection(rankings_bundle,ri,bad_rank,"league:live",0);});
const auto fr=rw({{"kind","fairplay"},{"leagueId","league:live"},{"season","2026/27"},{"weights",{{"yellow",1},{"red",4}}},{"recordedMatches",1},{"rows",{{{"rank",1},{"team",{{"id","club:6"},{"name","Live A"}}},{"yellow",1},{"red",0},{"points",1}},{{"rank",2},{"team",{{"id","club:7"},{"name","Live B"}}},{"yellow",0},{"red",1},{"points",4}}}}});
require(engine_fairplay_projection(rankings_bundle,ri,fr).at("rows").size()==2,"fairplay rows lost");auto bad_fair=fr;bad_fair["data"]["rows"][1]["points"]=1;rejects([&]{engine_fairplay_projection(rankings_bundle,ri,bad_fair);});
std::cout << "engine DTO, exact money, scope and booking tests passed\n";
return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }