From de682ca8f4908e058d4821684b13e35369bcc493 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Sep 2025 18:50:09 +0100 Subject: Simplify storeEntities with bindMany --- src/ingestor.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 6dd369e..cfdd87f 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -156,11 +156,10 @@ namespace WebStat { "host", "virtual_host", "path", "query_string", "referrer", "user_agent"}; 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, std::get<0>(*entity)); - insert->bindParamS(1, ENTITY_TYPE_VALUES[std::to_underlying(std::get<1>(*entity))]); - insert->bindParamS(2, std::get<2>(*entity)); + std::ranges::for_each( + values | std::views::take_while(&std::optional::has_value), [this, &insert](auto && entity) { + const auto & [entityId, type, value] = *entity; + bindMany(insert, 0, entityId, ENTITY_TYPE_VALUES[std::to_underlying(type)], value); insert->execute(); existingEntities.emplace(std::get<0>(*entity)); }); -- cgit v1.2.3