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
#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"
}
std::fprintf(stderr, "Foobarbaz?\n");
}
+
+ // add all finished screens to the auxilliary screens
+ std::vector<SkeletonGroup> finished_groups;
+ conn.perform(FetchListOfFinishedGroups(active_tournament.id, &finished_groups));
+
+ for (std::vector<SkeletonGroup>::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);
--- /dev/null
+#include "fetch_list_of_finished_groups.h"
+
+FetchListOfFinishedGroups::FetchListOfFinishedGroups(unsigned tournament, std::vector<SkeletonGroup> *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);
+ }
+}
--- /dev/null
+#ifndef _FETCH_LIST_OF_FINISHED_GROUPS_H
+#define _FETCH_LIST_OF_FINISHED_GROUPS_H 1
+
+#include <pqxx/transactor>
+#include <vector>
+#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<SkeletonGroup> *active;
+
+public:
+ FetchListOfFinishedGroups(unsigned tournament, std::vector<SkeletonGroup> *active);
+ void operator() (pqxx::transaction<> &t);
+};
+
+#endif /* !defined(_FETCH_LIST_OF_FINISHED_GROUPS_H) */