1 #include "fetch_needs_update.h"
3 FetchNeedsUpdate::FetchNeedsUpdate(struct timeval last_updated, unsigned tournament, unsigned round, unsigned parallel, bool *result)
4 : last_updated(last_updated), tournament(tournament), round(round), parallel(parallel), result(result)
8 void FetchNeedsUpdate::operator() (pqxx::transaction<> &t)
10 // as we don't seem to have proper handling for timestamps in libpqxx,
11 // let's ask the database do to the work for us
13 time_t lu = last_updated.tv_sec;
14 strftime(buf, 256, "%F %T", localtime(&lu));
16 pqxx::result res( t.exec(std::string("SELECT (last_updated > '") + buf + "') AS needs_update FROM bigscreen.active_groups WHERE "
17 "tournament=" + pqxx::to_string(tournament) + " AND "
18 "round=" + pqxx::to_string(round) + " AND "
19 "parallel=" + pqxx::to_string(parallel)) );
22 *result = res.at(0)["needs_update"].as(*result);
23 } catch (PGSTD::out_of_range &e) {