]> git.sesse.net Git - ccbs/blobdiff - bigscreen/fetch_top_scores_for_tournament.h
Actually fetch and display the top 10 scores.
[ccbs] / bigscreen / fetch_top_scores_for_tournament.h
diff --git a/bigscreen/fetch_top_scores_for_tournament.h b/bigscreen/fetch_top_scores_for_tournament.h
new file mode 100644 (file)
index 0000000..78492ed
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _FETCH_TOP_SCORES_FOR_TOURNAMENT_H
+#define _FETCH_TOP_SCORES_FOR_TOURNAMENT_H 1
+
+#include <pqxx/transactor>
+#include <vector>
+#include "widestring.h"
+
+struct TopScore {
+       widestring nick, title, shorttitle;
+       unsigned score;
+
+       bool operator< (const TopScore &other) const;
+};
+
+/* A transactor that fetches the best N scores for a given tournament */
+class FetchTopScoresForTournament : public pqxx::transactor<> {
+private:
+       unsigned tournament, num;
+       std::vector<TopScore> *scores;
+
+public:
+       FetchTopScoresForTournament(unsigned tournament, unsigned num, std::vector<TopScore> *scores);
+       void operator() (pqxx::transaction<> &t);
+};
+
+#endif /* !defined(_FETCH_TOP_SCORES_FOR_TOURNAMENT_H) */