From 84bd17328a4dc027e689ca7b2a85744d6e2b7cf5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Sep 2025 13:24:23 +0100 Subject: Create and perform UA lookup curl op when new user agent is encountered --- src/ingestor.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ingestor.cpp') diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 26bb289..c54ca53 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -1,5 +1,6 @@ #include "ingestor.hpp" #include "sql.hpp" +#include "uaLookup.hpp" #include "util.hpp" #include #include @@ -94,7 +95,12 @@ namespace WebStat { while (auto msg = curl_multi_info_read(curl.get(), &remaining)) { if (msg->msg == CURLMSG_DONE) { if (auto operationItr = curlOperations.find(msg->easy_handle); operationItr != curlOperations.end()) { - if (msg->data.result == CURLE_OK) { } + if (msg->data.result == CURLE_OK) { + operationItr->second->whenComplete(dbpool->get().get()); + } + else { + operationItr->second->onError(dbpool->get().get()); + } curl_multi_remove_handle(curl.get(), msg->easy_handle); curlOperations.erase(operationItr); } @@ -186,7 +192,18 @@ namespace WebStat { 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(); + if (insert->execute() > 0) { + switch (type) { + case EntityType::UserAgent: { + auto curlOp = curlGetUserAgentDetail(entityId, value, userAgentAPI.c_str()); + auto added = curlOperations.emplace(curlOp->hnd.get(), std::move(curlOp)); + curl_multi_add_handle(curl.get(), added.first->first); + break; + } + default: + break; + } + } existingEntities.emplace(std::get<0>(*entity)); }); } -- cgit v1.2.3