summaryrefslogtreecommitdiff
path: root/src/ingestor.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2026-05-05 12:24:11 +0100
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2026-05-05 12:24:11 +0100
commit200c3636b600ac2f997316612f1b1321112496cd (patch)
tree21a86b460e1dca04d5a403e56133383ab78881b6 /src/ingestor.cpp
parentf9b4422198281410218e371ffc3e1e4513a9ba7f (diff)
downloadwebstat-200c3636b600ac2f997316612f1b1321112496cd.tar.bz2
webstat-200c3636b600ac2f997316612f1b1321112496cd.tar.xz
webstat-200c3636b600ac2f997316612f1b1321112496cd.zip
Only call entity insert handler if detail is null
Improves handling of entity inserts where the entity already exists and already has detail; does not call the onInsert handler. This avoids repeatedly fetching UA detail every time the UA is first seen by a process.
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r--src/ingestor.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index 3e36d85..fe8d38c 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -562,8 +562,10 @@ namespace WebStat {
assert(!entity.id);
const auto & [typeName, onInsert] = ENTITY_TYPE_VALUES[std::to_underlying(entity.type)];
- entity.id = insert(dbconn, SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS, entity.value, typeName);
- if (onInsert) {
+ bool entityNullDetail = true;
+ std::tie(entity.id, entityNullDetail)
+ = insert<EntityId, bool>(dbconn, SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS, entity.value, typeName);
+ if (onInsert && entityNullDetail) {
std::invoke(onInsert, this, entity);
}
stats.entitiesInserted += 1;