Rewrite electricity-logger to use an sqlite3 database

This commit is contained in:
2022-06-25 22:17:46 +02:00
parent 458d824dc8
commit 5b09b06bcf
62 changed files with 5937 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
#pragma once
#include <pistache/http.h>
#include <pistache/router.h>
namespace Server::Api
{
void GetDay(Pistache::Http::Request const & request, Pistache::Http::ResponseWriter responseWrite);
void SetupRouting(Pistache::Rest::Router & router);
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include <chrono>
#include <mutex>
#include <string>
namespace Server
{
class Configuration {
private:
std::string logDirectory;
std::string serverDomain;
std::string lastExternalIp;
std::chrono::time_point<std::chrono::steady_clock> lastIpCheckTimePoint;
std::mutex externalIpRefreshMutex;
Configuration();
Configuration(Configuration & other) = delete;
Configuration(Configuration && other) = delete;
Configuration & operator=(Configuration & other) = delete;
Configuration & operator=(Configuration && other) = delete;
void RefreshExternalIp();
bool ExternalIpRequiresRefresh() const;
public:
void Setup(std::string & electricityLogDirectory, std::string const & serverDomain);
std::string const & GetLogDirectory() const;
std::string const & GetExternalServerIp();
static Configuration & Get();
};
}

View File

@@ -0,0 +1,8 @@
#include <string>
#include <util/date.hpp>
namespace Server::Database
{
std::string GetDetailedJsonOf(Util::Date const & date);
std::string GetSummaryJsonOf(Util::Date const & startDate, Util::Date const & stopDate);
}