[Repositories] Update repositories (#2040)

This commit is contained in:
Chris Miles
2022-03-11 15:27:36 -08:00
committed by GitHub
parent f22608a43a
commit 3ed6663c4c
170 changed files with 5543 additions and 511 deletions
@@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDataBucketsRepository {
public:
@@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"key",
"value",
"expires",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("data_buckets");
@@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@@ -110,7 +126,7 @@ public:
if (results.RowCount() == 1) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
@@ -241,7 +257,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
@@ -269,7 +285,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);