X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=bigscreen%2Ffetch_list_of_finished_groups.cpp;fp=bigscreen%2Ffetch_list_of_finished_groups.cpp;h=9d9de9536b1d3a8a91a21838b3eef3861657ae00;hp=0000000000000000000000000000000000000000;hb=295701bd0835259dcf72b57779e77eeded720baa;hpb=bb5b7a03fb40583ab3f7cfeabe17739c970d8c69 diff --git a/bigscreen/fetch_list_of_finished_groups.cpp b/bigscreen/fetch_list_of_finished_groups.cpp new file mode 100644 index 0000000..9d9de95 --- /dev/null +++ b/bigscreen/fetch_list_of_finished_groups.cpp @@ -0,0 +1,25 @@ +#include "fetch_list_of_finished_groups.h" + +FetchListOfFinishedGroups::FetchListOfFinishedGroups(unsigned tournament, std::vector *active) : + tournament(tournament), active(active) {} + +void FetchListOfFinishedGroups::operator() (pqxx::transaction<> &t) +{ + // make sure we start with an empty list + active->erase(active->begin(), active->end()); + + // find all groups with no empty scores that are not already shown on the bigscreen + pqxx::result res( t.exec("SELECT tournament,round,parallel FROM scores WHERE tournament=" + + pqxx::to_string(tournament) + " GROUP BY tournament,round,parallel HAVING COUNT(*)=COUNT(score) AND (tournament,round) NOT IN ( SELECT tournament,round FROM bigscreen.active_groups ) ORDER BY tournament,round,parallel") ); + + for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) { + SkeletonGroup g; + + g.tournament = i["tournament"].as(g.tournament); + g.round = i["round"].as(g.round); + g.parallel = i["parallel"].as(g.parallel); + g.num_machines = 1; + + active->push_back(g); + } +}