diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-10 18:50:09 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-10 18:50:09 +0100 |
commit | de682ca8f4908e058d4821684b13e35369bcc493 (patch) | |
tree | 781790c645e39c5f69871cce8940ff06318843d3 /src/ingestor.cpp | |
parent | c9b3d45d2598ebef2df889c0b9967ef473405528 (diff) | |
download | webstat-de682ca8f4908e058d4821684b13e35369bcc493.tar.bz2 webstat-de682ca8f4908e058d4821684b13e35369bcc493.tar.xz webstat-de682ca8f4908e058d4821684b13e35369bcc493.zip |
Simplify storeEntities with bindMany
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r-- | src/ingestor.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
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<Entity>::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<Entity>::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)); }); |