mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 21:22:25 +08:00
Fix analytics aggregstion with interval > 60s
This commit is contained in:
parent
0db3dd0d00
commit
5c879ccc49
@ -14,7 +14,7 @@ private:
|
||||
|
||||
std::atomic<bool> quit = false;
|
||||
|
||||
const size_t QUERY_COMPACTION_INTERVAL_S = 60;
|
||||
const size_t QUERY_COMPACTION_INTERVAL_S = 30;
|
||||
|
||||
struct suggestion_config_t {
|
||||
std::string name;
|
||||
|
@ -233,6 +233,15 @@ void AnalyticsManager::run(ReplicationState* raft_server) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto now_ts_seconds = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
|
||||
if(now_ts_seconds - prev_persistence_s < Config::get_instance().get_analytics_flush_interval()) {
|
||||
// we will persist aggregation every hour
|
||||
// LOG(INFO) << "QuerySuggestions::run interval is less, continuing";
|
||||
continue;
|
||||
}
|
||||
|
||||
persist_suggestions(raft_server, prev_persistence_s);
|
||||
prev_persistence_s = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
@ -264,13 +273,6 @@ void AnalyticsManager::persist_suggestions(ReplicationState *raft_server, uint64
|
||||
auto now_ts_us = std::chrono::duration_cast<std::chrono::microseconds>(now).count();
|
||||
popularQueries->compact_user_queries(now_ts_us);
|
||||
|
||||
auto now_ts_seconds = std::chrono::duration_cast<std::chrono::seconds>(now).count();
|
||||
|
||||
if(now_ts_seconds - prev_persistence_s < Config::get_instance().get_analytics_flush_interval()) {
|
||||
// we will persist aggregation every hour
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string import_payload;
|
||||
popularQueries->serialize_as_docs(import_payload);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user