From b7011711b3e2be943f3cf56c458d2ea74fedac4b Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 15 Dec 2024 23:20:47 -0600 Subject: [PATCH] Use build instead of build_record --- src/archive.cpp | 28 +++++++++++++++------------- src/archive.h | 11 ++++------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/archive.cpp b/src/archive.cpp index c5d18aa..61a770a 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -20,6 +20,7 @@ #include "archive_permission.h" #include "binary_package_publishing_history.h" #include "archive_dependency.h" +#include "build.h" #include #include @@ -244,9 +245,9 @@ std::optional archive::getBuildCounters(bool include_needsbuild) return nlohmann::json::parse(response.value()); } -std::generator archive::getBuildRecords(const std::string& build_state, - const std::string& pocket, - const std::string& source_name) const { +std::generator archive::getBuildRecords(const std::string& build_state, + const std::string& pocket, + const std::string& source_name) const { std::map params; params["ws.op"] = "getBuildRecords"; if(!build_state.empty()) params["build_state"] = build_state; @@ -258,9 +259,10 @@ std::generator archive::getBuildRecords(const std::string& build_s while (true) { if (data.contains("entries") && data["entries"].is_array()) { for (auto& e : data["entries"]) { - build_record br; - br.data = e; - co_yield br; + auto b_opt = build::parse(e.dump()); + if(!b_opt) continue; + b_opt->set_lp(lp); + co_yield b_opt.value(); } } if(!data.contains("next_collection_link") || data["next_collection_link"].is_null() || data["next_collection_link"]=="") break; @@ -558,7 +560,7 @@ std::generator archive::getUploadersForPocket(const std::str if(data.contains("entries")){ for(auto&e:data["entries"]){ auto ap=archive_permission::parse(e.dump()); - if(ap){ap->set_lp(lp); co_yield ap.value();} + if(ap){ap->set_lp(lp);co_yield ap.value();} } } } @@ -741,7 +743,7 @@ bool archive::markSuiteDirty(const std::string& distroseries, } std::optional archive::newComponentUploader(const std::string& component_name, - const std::string& person) const { + const std::string& person) const { std::mapparams; params["ws.op"]="newComponentUploader"; params["component_name"]=component_name; @@ -779,7 +781,7 @@ std::optional archive::newNamedAuthTokens(const std::vector archive::newPackageUploader(const std::string& person, - const std::string& source_package_name) const { + const std::string& source_package_name) const { std::mapparams; params["ws.op"]="newPackageUploader"; params["person"]=person; @@ -807,8 +809,8 @@ std::optional archive::newPackagesetUploader(const std::stri } std::optional archive::newPocketQueueAdmin(const std::string& distroseries, - const std::string& person, - const std::string& pocket) const { + const std::string& person, + const std::string& pocket) const { std::mapparams; params["ws.op"]="newPocketQueueAdmin"; if(!distroseries.empty())params["distroseries"]=distroseries; @@ -822,7 +824,7 @@ std::optional archive::newPocketQueueAdmin(const std::string } std::optional archive::newPocketUploader(const std::string& person, - const std::string& pocket) const { + const std::string& pocket) const { std::mapparams; params["ws.op"]="newPocketUploader"; params["person"]=person; @@ -835,7 +837,7 @@ std::optional archive::newPocketUploader(const std::string& } std::optional archive::newQueueAdmin(const std::string& component_name, - const std::string& person) const { + const std::string& person) const { std::mapparams; params["ws.op"]="newQueueAdmin"; params["component_name"]=component_name; diff --git a/src/archive.h b/src/archive.h index e18d7ae..5f6fdbc 100644 --- a/src/archive.h +++ b/src/archive.h @@ -20,6 +20,7 @@ #include "archive_permission.h" #include "binary_package_publishing_history.h" #include "archive_dependency.h" +#include "build.h" #include #include #include @@ -36,10 +37,6 @@ class launchpad; -struct build_record { - nlohmann::json data; -}; - class archive { public: archive(); @@ -102,9 +99,9 @@ public: bool strict_component = false) const; std::optional getArchiveDependency(const std::string& dependency_link) const; std::optional getBuildCounters(bool include_needsbuild = false) const; - std::generator getBuildRecords(const std::string& build_state = "", - const std::string& pocket = "", - const std::string& source_name = "") const; + std::generator getBuildRecords(const std::string& build_state = "", + const std::string& pocket = "", + const std::string& source_name = "") const; std::optional getBuildSummariesForSourceIds(const std::vector& source_ids) const; std::generator getComponentsForQueueAdmin(const std::string& person_link) const; std::optional getNamedAuthToken(const std::string& name) const;