summaryrefslogtreecommitdiff
path: root/src/ingestor.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2026-07-09 13:09:34 +0100
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2026-07-09 13:09:34 +0100
commitfa277f69b14446b47a3dfa63ed7fc1a8a16ef7f8 (patch)
treea740ad434e192676ccab12f6a3ab2821902b58c1 /src/ingestor.cpp
parentf8d326a7d6f49a6b6009a7869ce61d782ad9c7b6 (diff)
downloadwebstat-0.7.1.tar.bz2
webstat-0.7.1.tar.xz
webstat-0.7.1.zip
Include type in existingEntities cacheHEADwebstat-0.7.1main
Fixes the issues of entities having the same value (hash) but occurring in different places. This is most often when the client states the virtual host name as the referrer.
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r--src/ingestor.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index 41dd24f..ebff00b 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -53,9 +53,11 @@ namespace WebStat {
operator()(const std::string_view value) const
{
return {
- .hash = makeHash(value),
+ .key = {
+ .hash = makeHash(value),
+ .type = Type,
+ },
.id = std::nullopt,
- .type = Type,
.value = value,
};
}
@@ -331,7 +333,7 @@ namespace WebStat {
}
constexpr auto ENTITY_IDS = std::views::transform([](auto && value) {
- return std::make_pair(value->hash, *value->id);
+ return std::tie(value->key, *value->id);
});
Ingestor::Job::Result
@@ -610,7 +612,7 @@ namespace WebStat {
{
auto lockedEntities = existingEntities.shared();
for (const auto entity : entities) {
- if (auto existing = lockedEntities->find(entity->hash); existing != lockedEntities->end()) {
+ if (auto existing = lockedEntities->find(entity->key); existing != lockedEntities->end()) {
entity->id = existing->second;
}
}
@@ -644,7 +646,7 @@ namespace WebStat {
}};
assert(!entity.id);
- const auto & [typeName, onInsert] = ENTITY_TYPE_VALUES[std::to_underlying(entity.type)];
+ const auto & [typeName, onInsert] = ENTITY_TYPE_VALUES[std::to_underlying(entity.key.type)];
bool entityNullDetail = true;
std::tie(entity.id, entityNullDetail)
= insert<EntityId, bool>(dbconn, SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS, entity.value, typeName);
@@ -671,7 +673,7 @@ namespace WebStat {
void
Ingestor::onNewUserAgent(const Entity & entity) const
{
- const auto & [entityHash, entityId, type, value] = entity;
+ const auto & [_, entityId, value] = entity;
auto curlOp = curlGetUserAgentDetail(*entityId, value, settings.userAgentAPI.c_str());
{
std::lock_guard curlOperationsLock {curlOperationsMutex};