X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=bigscreen%2Ffetch_current_tournament.cpp;fp=bigscreen%2Ffetch_current_tournament.cpp;h=364d8b34ca05b6beac0e9bd49140dce218ebb7d0;hp=0000000000000000000000000000000000000000;hb=2561f34f160440e5df8c3891a50d6e3c2b83c715;hpb=141adc9f5acb9ed1e98a206abb0d2e9cfdce6d2f diff --git a/bigscreen/fetch_current_tournament.cpp b/bigscreen/fetch_current_tournament.cpp new file mode 100644 index 0000000..364d8b3 --- /dev/null +++ b/bigscreen/fetch_current_tournament.cpp @@ -0,0 +1,16 @@ +#include "fetch_current_tournament.h" + +FetchCurrentTournament::FetchCurrentTournament(Tournament *tourn) : tourn(tourn) {} +void FetchCurrentTournament::operator() (pqxx::transaction<> &t) +{ + pqxx::result res( t.exec("SELECT * FROM bigscreen.active_tournament NATURAL JOIN tournaments") ); + try { + pqxx::result::tuple tournament = res.at(0); + + tourn->id = tournament["tournament"].as(tourn->id); + tourn->name = tournament["tournamentname"].as(tourn->name); + } catch (PGSTD::out_of_range &e) { + tourn->id = -1; + tourn->name = ""; + } +}