From e8a0fb7b9c61d5603a86b52e0f2144a91fd1d84e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 17 May 2026 17:45:53 +0100 Subject: Extract ENTITY_IDS helper Transform view for getting just the hash and record of a stored entity. --- src/ingestor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index e8dceb8..9f30263 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -334,6 +334,10 @@ namespace WebStat { }; } + constexpr auto ENTITY_IDS = std::views::transform([](auto && value) { + return std::make_pair(value->hash, *value->id); + }); + template std::vector Ingestor::entities(std::tuple & values) @@ -358,10 +362,6 @@ namespace WebStat { void Ingestor::ingestLogLines(DB::Connection * dbconn, const LinesView lines) { - auto entityIds = std::views::transform([](auto && value) { - return std::make_pair(value->hash, *value->id); - }); - DB::TransactionScope batchTx {*dbconn}; for (const auto & line : lines) { if (auto result = scanLogLine(line)) { @@ -372,7 +372,7 @@ namespace WebStat { try { DB::TransactionScope lineTx {*dbconn}; storeNewEntities(dbconn, valuesEntities); - existingEntities()->insert_range(valuesEntities | entityIds); + existingEntities()->insert_range(valuesEntities | ENTITY_IDS); storeLogLine(dbconn, values); } catch (const DB::Error & originalError) { -- cgit v1.3