]> git.sesse.net Git - ccbs/blob - bigscreen/fetch_max_score_for_players.cpp
There is no freshcolumnheading.
[ccbs] / bigscreen / fetch_max_score_for_players.cpp
1 #include "fetch_max_score_for_players.h"
2
3 FetchMaxScoreForPlayers::FetchMaxScoreForPlayers(unsigned tournament, unsigned round, std::map<unsigned, unsigned> *scores)
4         : tournament(tournament), round(round), scores(scores) {}
5         
6 void FetchMaxScoreForPlayers::operator() (pqxx::transaction<> &t)
7 {
8         scores->erase(scores->begin(), scores->end());
9         
10         pqxx::result res( t.exec("SELECT * FROM get_max_score_for_players("
11                 + pqxx::to_string(tournament) + ", " + pqxx::to_string(round) +
12                 ", 'single')") );
13         
14         for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
15                 unsigned player, max_score;
16                 player = i["song"].as(player);
17                 max_score = i["max_score"].as(max_score);
18
19                 scores->insert(std::make_pair(player, max_score));
20         }
21 }