From 200c3636b600ac2f997316612f1b1321112496cd Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 5 May 2026 12:24:11 +0100 Subject: 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. --- src/ingestor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ingestor.cpp') 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(dbconn, SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS, entity.value, typeName); + if (onInsert && entityNullDetail) { std::invoke(onInsert, this, entity); } stats.entitiesInserted += 1; -- cgit v1.3