From: Steinar H. Gunderson Date: Tue, 1 Mar 2005 00:24:48 +0000 (+0000) Subject: The auxilliary screen now also shows all finished groups. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=295701bd0835259dcf72b57779e77eeded720baa;hp=bb5b7a03fb40583ab3f7cfeabe17739c970d8c69 The auxilliary screen now also shows all finished groups. --- diff --git a/bigscreen/Makefile b/bigscreen/Makefile index ec59011..d58b48e 100644 --- a/bigscreen/Makefile +++ b/bigscreen/Makefile @@ -6,6 +6,7 @@ LDFLAGS=-L/usr/X11R6/lib LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11 -lXext CCBS_BIGSCREEN_SQL_OBJS=fetch_current_tournament.o fetch_list_of_active_groups.o \ + fetch_list_of_finished_groups.o \ fetch_max_score_for_songs.o fetch_max_score_for_players.o fetch_group.o \ fetch_needs_update.o fetch_highscore.o fetch_top_scores_for_tournament.o \ fetch_top_chosen_songs_for_tournament.o fetch_auxilliary_screens.o diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 5830356..0892c16 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -8,6 +8,7 @@ #include "widestring.h" #include "fetch_current_tournament.h" #include "fetch_list_of_active_groups.h" +#include "fetch_list_of_finished_groups.h" #include "fetch_group.h" #include "fetch_auxilliary_screens.h" #include "fonts.h" @@ -71,6 +72,14 @@ void init(pqxx::connection &conn) } std::fprintf(stderr, "Foobarbaz?\n"); } + + // add all finished screens to the auxilliary screens + std::vector finished_groups; + conn.perform(FetchListOfFinishedGroups(active_tournament.id, &finished_groups)); + + for (std::vector::const_iterator i = finished_groups.begin(); i != finished_groups.end(); ++i) { + aux_screen->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel, 0, 1)); + } // hack screens.push_back(NULL); 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); + } +} diff --git a/bigscreen/fetch_list_of_finished_groups.h b/bigscreen/fetch_list_of_finished_groups.h new file mode 100644 index 0000000..598086d --- /dev/null +++ b/bigscreen/fetch_list_of_finished_groups.h @@ -0,0 +1,22 @@ +#ifndef _FETCH_LIST_OF_FINISHED_GROUPS_H +#define _FETCH_LIST_OF_FINISHED_GROUPS_H 1 + +#include +#include +#include "fetch_list_of_active_groups.h" + +/* + * A transactor that fetches the current list of finished groups (ie. parallels + * with no non-NULL scores, that are not shown elsewhere on the bigscreen). + */ +class FetchListOfFinishedGroups : public pqxx::transactor<> { +private: + unsigned tournament; + std::vector *active; + +public: + FetchListOfFinishedGroups(unsigned tournament, std::vector *active); + void operator() (pqxx::transaction<> &t); +}; + +#endif /* !defined(_FETCH_LIST_OF_FINISHED_GROUPS_H) */