From 53a42351b97db6c84fb930b9eb9c89d694956bca Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 29 Aug 2025 05:42:40 +0100 Subject: Reuse same insert entity command --- src/ingestor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 5c47ab7..00bad64 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -138,9 +138,9 @@ namespace WebStat { void Ingestor::storeEntities(DB::Connection * dbconn, const std::span> values) const { - std::ranges::for_each( - values | std::views::take_while(&std::optional::has_value), [this, dbconn](auto && entity) { - auto insert = dbconn->modify(SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS); + auto insert = dbconn->modify(SQL::ENTITY_INSERT, SQL::ENTITY_INSERT_OPTS); + std::ranges::for_each(values | std::views::take_while(&std::optional::has_value), + [this, insert = insert.get()](auto && entity) { insert->bindParamI(0, entity->first); insert->bindParamS(1, entity->second); insert->execute(); -- cgit v1.2.3