diff --git a/src/source_package_publishing_history.cpp b/src/source_package_publishing_history.cpp index be391a7..6b4ae3c 100644 --- a/src/source_package_publishing_history.cpp +++ b/src/source_package_publishing_history.cpp @@ -14,6 +14,7 @@ // along with this program. If not, see . #include "source_package_publishing_history.h" +#include "binary_package_publishing_history.h" #include "build.h" #include "launchpad.h" #include @@ -91,3 +92,25 @@ const std::optional source_package_publishing_history::getD } return std::nullopt; } + +std::generator source_package_publishing_history::getPublishedBinaries(bool active_binaries_only) const { + std::map params; + params["ws.op"] = "getPublishedBinaries"; + if (active_binaries_only) params["active_binaries_only"] = "true"; + + auto response=lp->api_get(self_link, params); + if(!response) co_return; + auto data = nlohmann::json::parse(response.value()); + while (true) { + if (data.contains("entries") && data["entries"].is_array()) { + for (auto &e : data["entries"]) { + auto bpph = binary_package_publishing_history::parse(e.dump()); + if (bpph) { bpph->set_lp(lp); co_yield bpph.value(); } + } + } + if(!data.contains("next_collection_link")||data["next_collection_link"].is_null()||data["next_collection_link"]=="")break; + response=lp->api_get(data["next_collection_link"].get()); + if(!response)break; + data=nlohmann::json::parse(response.value()); + } +} diff --git a/src/source_package_publishing_history.h b/src/source_package_publishing_history.h index 4799c1b..e381170 100644 --- a/src/source_package_publishing_history.h +++ b/src/source_package_publishing_history.h @@ -20,6 +20,7 @@ #include #include #include "distro_series.h" +#include "binary_package_publishing_history.h" class launchpad; class build; @@ -42,6 +43,7 @@ public: std::generator getBuilds() const; std::optional distro_series = getDistroSeries(); + std::generator getPublishedBinaries(bool active_binaries_only = false) const; std::string distro_series_link; std::string self_link;