]> git.sesse.net Git - ccbs/blobdiff - bigscreen/fetch_group.cpp
Only allocate space for four digits in the score screen -- if somebody actually gets...
[ccbs] / bigscreen / fetch_group.cpp
index 7962897ca328a7eb9a7f2fae5a04ebfe873d03e6..bdaa0c9a9b309e469e24fde3db634eb51d983030 100644 (file)
@@ -5,7 +5,8 @@ FetchGroup::FetchGroup(unsigned tournament, unsigned round, unsigned parallel, G
        
 void FetchGroup::operator() (pqxx::transaction<> &t)
 {
-       pqxx::result res( t.exec("SELECT round,parallel,position,playmode,difficulty,songnumber,player,nick,song,title,artist,chosen,score FROM roundparticipation NATURAL JOIN players NATURAL JOIN scores NATURAL LEFT JOIN songs WHERE " 
+       // note: this _will_ break if any song has more than one short title!
+       pqxx::result res( t.exec("SELECT round,parallel,position,playmode,difficulty,songnumber,player,nick,song,title,COALESCE(shorttitle,title) AS shorttitle,artist,chosen,score FROM roundparticipation NATURAL JOIN players NATURAL JOIN scores NATURAL LEFT JOIN songs NATURAL LEFT JOIN songshorttitles WHERE " 
                "tournament=" + pqxx::to_string(tournament) + " AND " +
                "round=" + pqxx::to_string(round) + " AND " +
                "parallel=" + pqxx::to_string(parallel) + " " +
@@ -39,8 +40,9 @@ void FetchGroup::operator() (pqxx::transaction<> &t)
                        so.id = -1;
                } else {
                        so.id = i["song"].as(so.id);
-                       so.title = i["song"].as(so.title);
-                       so.artist = i["song"].as(so.artist);
+                       so.title = i["title"].as(so.title);
+                       so.artist = i["artist"].as(so.artist);
+                       so.short_title = i["shorttitle"].as(so.short_title);
                }
        
                sc.song = so;
@@ -52,8 +54,6 @@ void FetchGroup::operator() (pqxx::transaction<> &t)
                        sc.score = i["score"].as(sc.score);
                }
 
-               std::printf("score: %u\n", sc.score);
-               
                curr_group.players[curr_group.players.size() - 1].scores.push_back(sc);
        }
 }