]> git.sesse.net Git - ccbs/blob - bigscreen/fetch_max_score_for_song.cpp
Fetch the actual high score from the database when showing high score on the group...
[ccbs] / bigscreen / fetch_max_score_for_song.cpp
1 #include "fetch_max_score_for_song.h"
2
3 FetchMaxScoreForSong::FetchMaxScoreForSong(unsigned tournament, unsigned song, unsigned *score)
4         : tournament(tournament), song(song), score(score) {}
5         
6 void FetchMaxScoreForSong::operator() (pqxx::transaction<> &t)
7 {
8         pqxx::result res( t.exec("SELECT MAX(feetrating)*1000 AS max_score FROM songratings WHERE song=" +
9                 pqxx::to_string(song) + " AND machine=( SELECT machine FROM tournaments WHERE tournament=" +
10                 pqxx::to_string(tournament) + ")") );
11         
12         *score = res.at(0)["max_score"].as(*score);
13 }