Добавил C++-сервер

This commit is contained in:
2024-01-15 03:50:14 +03:00
parent 97387befe1
commit 68e421b336
46 changed files with 919 additions and 0 deletions
@@ -0,0 +1,21 @@
#include <sstream>
#include <controllers/statistics/query.h>
#include <storage/postgresql/postgresql_storage.h>
std::vector<StatisticsRow> StatisticsQuery() {
std::ostringstream query;
query << "select name, value from statistics;";
auto pqxx_result = PostgreSqlStorage::Get().Do(query.str());
std::vector<StatisticsRow> result;
result.reserve(pqxx_result.size());
for (const auto& row : pqxx_result) {
StatisticsRow statistics_row{ row[0].as<std::string>(), row[1].as<size_t>() };
result.push_back(std::move(statistics_row));
}
return result;
}