summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-05-17 17:45:53 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2026-05-17 17:45:53 +0100
commite8a0fb7b9c61d5603a86b52e0f2144a91fd1d84e (patch)
tree9f508464403d314183b4acde0124f2b7358d6c9a
parent7b1aeee4565fe0a2eed4a4fa8695b2a5fb671e06 (diff)
downloadwebstat-e8a0fb7b9c61d5603a86b52e0f2144a91fd1d84e.tar.bz2
webstat-e8a0fb7b9c61d5603a86b52e0f2144a91fd1d84e.tar.xz
webstat-e8a0fb7b9c61d5603a86b52e0f2144a91fd1d84e.zip
Extract ENTITY_IDS helper
Transform view for getting just the hash and record of a stored entity.
-rw-r--r--src/ingestor.cpp10
1 files changed, 5 insertions, 5 deletions
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<typename... T>
std::vector<Entity *>
Ingestor::entities(std::tuple<T...> & 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) {