Обновление слоя хранилища

This commit is contained in:
2024-02-23 20:05:05 +03:00
parent 6baee0ca6b
commit c0c3197cf2
18 changed files with 150 additions and 163 deletions
@@ -2,14 +2,16 @@
#include <sstream>
#include <storage/postgresql/postgresql_storage.h>
#include <storage/transaction.h>
namespace controllers::anomaly_logs::details {
std::vector<AnomalyLog> GetAnomalyLogs(int64_t last_id) {
auto transaction = storage::Transaction::Create();
std::ostringstream query;
query << "select id, cluster_id, data from anomaly_logs where id > " << last_id << ";";
auto pqxx_result = PostgreSqlStorage::Get().Do(query.str());
auto pqxx_result = transaction.Do(query.str());
std::vector<AnomalyLog> result;
result.reserve(pqxx_result.size());
@@ -5,9 +5,7 @@
namespace controllers::anomaly_logs::details {
struct AnomalyLog {
int64_t id;
int64_t class_id;
std::string data;
};
std::vector<AnomalyLog> GetAnomalyLogs(int64_t last_id);
@@ -2,14 +2,16 @@
#include <sstream>
#include <storage/postgresql/postgresql_storage.h>
#include <storage/transaction.h>
namespace controllers::logs_clusters::details {
std::vector<LogsCluster> GetLogsClusters() {
auto transaction = storage::Transaction::Create();
std::ostringstream query;
query << "select id, name, description, recommendation from logs_clusters;";
auto pqxx_result = PostgreSqlStorage::Get().Do(query.str());
auto pqxx_result = transaction.Do(query.str());
std::vector<LogsCluster> result;
result.reserve(pqxx_result.size());
@@ -2,14 +2,16 @@
#include <sstream>
#include <storage/postgresql/postgresql_storage.h>
#include <storage/transaction.h>
namespace controllers::statistics::details {
std::vector<Statistic> GetStatistics() {
auto transaction = storage::Transaction::Create();
std::ostringstream query;
query << "select name, value from statistics;";
auto pqxx_result = PostgreSqlStorage::Get().Do(query.str());
auto pqxx_result = transaction.Do(query.str());
std::vector<Statistic> result;
result.reserve(pqxx_result.size());