]> git.sesse.net Git - ccbs/commitdiff
The auxilliary screen now also shows all finished groups.
authorSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 00:24:48 +0000 (00:24 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 00:24:48 +0000 (00:24 +0000)
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/fetch_list_of_finished_groups.cpp [new file with mode: 0644]
bigscreen/fetch_list_of_finished_groups.h [new file with mode: 0644]

index ec590118fe6b99d240aac03a0bb297c695ee2092..d58b48e24f53d408aa566d857e6ab141d3d84202 100644 (file)
@@ -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
index 583035619994ac15f41fd5f3afb64babd97776de..0892c16a7f66d26d4a619f36fd78e63edf12647a 100644 (file)
@@ -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<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);
diff --git a/bigscreen/fetch_list_of_finished_groups.cpp b/bigscreen/fetch_list_of_finished_groups.cpp
new file mode 100644 (file)
index 0000000..9d9de95
--- /dev/null
@@ -0,0 +1,25 @@
+#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);
+       }
+}
diff --git a/bigscreen/fetch_list_of_finished_groups.h b/bigscreen/fetch_list_of_finished_groups.h
new file mode 100644 (file)
index 0000000..598086d
--- /dev/null
@@ -0,0 +1,22 @@
+#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) */