Added vol/theo archiving to AnalyticsService
This commit is contained in:
1 parent
fb2fd21417
commit
f9c79d5b44
3 files changed
+61
-6
No files matched your search
@@ -14,6 +14,7 @@
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
@@ -22,6 +23,14 @@ using namespace bts::api::analytics;
|
||||
|
||||
namespace bts::analytics {
|
||||
|
||||
uint64_t get_epoch() {
|
||||
using namespace std::chrono;
|
||||
milliseconds ms =
|
||||
duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
uint64_t ms_u = ms.count();
|
||||
return ms_u;
|
||||
}
|
||||
|
||||
// assumes key are ints
|
||||
int get_max_id(IStore *const store, const std::string &ns) {
|
||||
auto ns_map = store->retrieve_all();
|
||||
@@ -68,10 +77,12 @@ struct AnalyticsServiceServer::PImpl {
|
||||
const std::string exp_params_ns = "analytics_expiration_params";
|
||||
const std::string vs_usage_ns = "volsurface_usage";
|
||||
const std::string reports_ns = "reports";
|
||||
const std::string archived_theos_ns = "archived_theos";
|
||||
std::unique_ptr<persistence::IStore> vs_store;
|
||||
std::unique_ptr<persistence::IStore> exp_params_store;
|
||||
std::unique_ptr<persistence::IStore> vs_usage_store;
|
||||
std::unique_ptr<persistence::IStore> reports_store;
|
||||
std::unique_ptr<persistence::IStore> theos_store;
|
||||
AnalyticsServiceBase::VolsurfacesStatefulPublisher vs_publisher;
|
||||
AnalyticsServiceBase::Exp_parametersStatefulPublisher exp_params_publisher;
|
||||
AnalyticsServiceBase::Volsurface_usageStatefulPublisher vs_usage_publisher;
|
||||
@@ -91,6 +102,8 @@ struct AnalyticsServiceServer::PImpl {
|
||||
vs_usage_store(
|
||||
std::make_unique<persistence::SqliteStore>("volsurface_usage")),
|
||||
reports_store(std::make_unique<persistence::SqliteStore>("reports")),
|
||||
theos_store(
|
||||
std::make_unique<persistence::SqliteStore>("archived_theos")),
|
||||
vs_publisher(vs_publisher), exp_params_publisher(exp_params_publisher),
|
||||
vs_usage_publisher(vs_usage_publisher),
|
||||
reports_publisher(reports_publisher) {}
|
||||
@@ -187,10 +200,7 @@ void AnalyticsServiceServer::get_new_volsurface_id(
|
||||
void AnalyticsServiceServer::save_volsurface(
|
||||
const bts::api::analytics::VolSurfaceEntry &vs_entry_arg,
|
||||
const api::Response<::bts::api::ResultMessage> &response) {
|
||||
using namespace std::chrono;
|
||||
milliseconds ms =
|
||||
duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
uint64_t ms_u = ms.count();
|
||||
uint64_t ms_u = get_epoch();
|
||||
VolSurfaceEntry vs_entry = vs_entry_arg;
|
||||
vs_entry.set_save_time(ms_u);
|
||||
// namespace: volsurface_<vs-name>_<vs-id>
|
||||
@@ -338,6 +348,19 @@ void AnalyticsServiceServer::delete_report(
|
||||
resp(res);
|
||||
}
|
||||
|
||||
void AnalyticsServiceServer::archive_theos(
|
||||
const bts::api::analytics::ArchivedTheoList &theo_list,
|
||||
const api::Response<::bts::api::ResultMessage> &) {
|
||||
const std::string &ns = me->archived_theos_ns;
|
||||
const std::string key = std::to_string(theo_list.save_time());
|
||||
std::string value = utils::pb::to_string(theo_list);
|
||||
me->theos_store->insert(ns, key, value);
|
||||
}
|
||||
|
||||
void AnalyticsServiceServer::get_archived_theos(
|
||||
const bts::api::analytics::ArchivedTheoRetrieval &,
|
||||
const bts::api::Response<bts::api::analytics::ArchivedTheoList> &) {}
|
||||
|
||||
AnalyticsServiceServer::~AnalyticsServiceServer() {}
|
||||
|
||||
} // namespace bts::analytics
|
||||
Reference in new issue
Block a user