Add source_package_publishing_history::getPublishedBinaries()

main
Simon Quigley 6 days ago
parent 7655cefedd
commit e99b2ef058

@ -14,6 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "source_package_publishing_history.h"
#include "binary_package_publishing_history.h"
#include "build.h"
#include "launchpad.h"
#include <iostream>
@ -91,3 +92,25 @@ const std::optional<class distro_series> source_package_publishing_history::getD
}
return std::nullopt;
}
std::generator<binary_package_publishing_history> source_package_publishing_history::getPublishedBinaries(bool active_binaries_only) const {
std::map<std::string,std::string> 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<std::string>());
if(!response)break;
data=nlohmann::json::parse(response.value());
}
}

@ -20,6 +20,7 @@
#include <optional>
#include <generator>
#include "distro_series.h"
#include "binary_package_publishing_history.h"
class launchpad;
class build;
@ -42,6 +43,7 @@ public:
std::generator<build> getBuilds() const;
std::optional<class distro_series> distro_series = getDistroSeries();
std::generator<binary_package_publishing_history> getPublishedBinaries(bool active_binaries_only = false) const;
std::string distro_series_link;
std::string self_link;

Loading…
Cancel
Save