mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 06:02:26 +08:00
updating responses, snapshot analytics dir when it's provided
This commit is contained in:
parent
bbdf4d717e
commit
b468311328
@ -259,7 +259,8 @@ Option<bool> AnalyticsManager::add_click_event(const std::string &query_collecti
|
||||
return Option<bool>(true);
|
||||
}
|
||||
|
||||
return Option<bool>(500, "Analytics Directory not provided.");
|
||||
LOG(ERROR) << "Analytics Directory not provided.";
|
||||
return Option<bool>(true);
|
||||
}
|
||||
|
||||
void AnalyticsManager::run(ReplicationState* raft_server) {
|
||||
|
@ -2803,7 +2803,7 @@ bool get_click_events(const std::shared_ptr<http_req>& req, const std::shared_pt
|
||||
auto click_events = AnalyticsManager::get_instance().get_click_events();
|
||||
|
||||
if(click_events.empty()) {
|
||||
res->set_400(click_events.dump());
|
||||
res->set_200(click_events.dump());
|
||||
}
|
||||
|
||||
res->set_200(click_events.dump());
|
||||
|
@ -493,13 +493,16 @@ void* ReplicationState::save_snapshot(void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
//add analytics db snapshot files to writer state
|
||||
butil::FileEnumerator analytics_dir_enum(butil::FilePath(sa->analytics_db_snapshot_path), false, butil::FileEnumerator::FILES);
|
||||
for (butil::FilePath file = analytics_dir_enum.Next(); !file.empty(); file = analytics_dir_enum.Next()) {
|
||||
auto file_name = std::string(analytics_db_snapshot_name) + "/" + file.BaseName().value();
|
||||
if (sa->writer->add_file(file_name) != 0) {
|
||||
sa->done->status().set_error(EIO, "Fail to add analytics file to writer.");
|
||||
return nullptr;
|
||||
if(!sa->analytics_db_snapshot_path.empty()) {
|
||||
//add analytics db snapshot files to writer state
|
||||
butil::FileEnumerator analytics_dir_enum(butil::FilePath(sa->analytics_db_snapshot_path), false,
|
||||
butil::FileEnumerator::FILES);
|
||||
for (butil::FilePath file = analytics_dir_enum.Next(); !file.empty(); file = analytics_dir_enum.Next()) {
|
||||
auto file_name = std::string(analytics_db_snapshot_name) + "/" + file.BaseName().value();
|
||||
if (sa->writer->add_file(file_name) != 0) {
|
||||
sa->done->status().set_error(EIO, "Fail to add analytics file to writer.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -590,9 +593,12 @@ void ReplicationState::on_snapshot_save(braft::SnapshotWriter* writer, braft::Cl
|
||||
arg->writer = writer;
|
||||
arg->state_dir_path = raft_dir_path;
|
||||
arg->db_snapshot_path = db_snapshot_path;
|
||||
arg->analytics_db_snapshot_path = analytics_db_snapshot_path;
|
||||
arg->done = done;
|
||||
|
||||
if(analytics_store) {
|
||||
arg->analytics_db_snapshot_path = analytics_db_snapshot_path;
|
||||
}
|
||||
|
||||
if(!ext_snapshot_path.empty()) {
|
||||
arg->ext_snapshot_path = ext_snapshot_path;
|
||||
ext_snapshot_path = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user