mu: refactor labels code

Split labels-cache and store-labels.
This commit is contained in:
Dirk-Jan C. Binnema
2025-09-02 23:19:54 +03:00
committed by Seth Ladygo
parent 152182a567
commit 3a12c69b10
11 changed files with 256 additions and 188 deletions

View File

@ -18,30 +18,14 @@
*/
#include "mu-store-labels.hh"
#include <istream>
#include <sstream>
#include "mu-store.hh"
#include "message/mu-labels.hh"
using namespace Mu;
Result<void>
Mu::LabelsCache::restore(const Store& store)
{
const auto res{store.run_query("")};
if (!res)
return Err(Error{Error::Code::Query,
"failed to run query: {}",
*res.error().what()});
label_map_.clear();
for (auto&& item: *res) {
if (auto &&msg{item.message()}; msg) {
for (const auto& label: msg->labels())
increase(label);
}
}
return Ok();
}
namespace {
constexpr std::string_view path_key = "path:";
constexpr std::string_view message_id_key = "message-id:";