1 #include "fetch_max_score_for_songs.h"
3 FetchMaxScoreForSongs::FetchMaxScoreForSongs(unsigned tournament, std::map<unsigned, unsigned> *score)
4 : tournament(tournament), score(score) {}
6 void FetchMaxScoreForSongs::operator() (pqxx::transaction<> &t)
8 score->erase(score->begin(), score->end());
10 pqxx::result res( t.exec("SELECT song,MAX(feetrating)*1000 AS max_score FROM songratings WHERE "
11 " machine=( SELECT machine FROM tournaments WHERE tournament=" + pqxx::to_string(tournament) + ") AND playmode='single' GROUP BY song") );
13 for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
14 unsigned song, max_score;
15 song = i["song"].as(song);
16 max_score = i["max_score"].as(max_score);
18 score->insert(std::make_pair(song, max_score));