Добавил C++-сервер
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user