Use build instead of build_record

main
Simon Quigley 1 week ago
parent 2cbe2897a2
commit b7011711b3

@ -20,6 +20,7 @@
#include "archive_permission.h" #include "archive_permission.h"
#include "binary_package_publishing_history.h" #include "binary_package_publishing_history.h"
#include "archive_dependency.h" #include "archive_dependency.h"
#include "build.h"
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
@ -244,9 +245,9 @@ std::optional<nlohmann::json> archive::getBuildCounters(bool include_needsbuild)
return nlohmann::json::parse(response.value()); return nlohmann::json::parse(response.value());
} }
std::generator<build_record> archive::getBuildRecords(const std::string& build_state, std::generator<build> archive::getBuildRecords(const std::string& build_state,
const std::string& pocket, const std::string& pocket,
const std::string& source_name) const { const std::string& source_name) const {
std::map<std::string,std::string> params; std::map<std::string,std::string> params;
params["ws.op"] = "getBuildRecords"; params["ws.op"] = "getBuildRecords";
if(!build_state.empty()) params["build_state"] = build_state; if(!build_state.empty()) params["build_state"] = build_state;
@ -258,9 +259,10 @@ std::generator<build_record> archive::getBuildRecords(const std::string& build_s
while (true) { while (true) {
if (data.contains("entries") && data["entries"].is_array()) { if (data.contains("entries") && data["entries"].is_array()) {
for (auto& e : data["entries"]) { for (auto& e : data["entries"]) {
build_record br; auto b_opt = build::parse(e.dump());
br.data = e; if(!b_opt) continue;
co_yield br; 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; if(!data.contains("next_collection_link") || data["next_collection_link"].is_null() || data["next_collection_link"]=="") break;
@ -558,7 +560,7 @@ std::generator<archive_permission> archive::getUploadersForPocket(const std::str
if(data.contains("entries")){ if(data.contains("entries")){
for(auto&e:data["entries"]){ for(auto&e:data["entries"]){
auto ap=archive_permission::parse(e.dump()); 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_permission> archive::newComponentUploader(const std::string& component_name, std::optional<archive_permission> archive::newComponentUploader(const std::string& component_name,
const std::string& person) const { const std::string& person) const {
std::map<std::string,std::string>params; std::map<std::string,std::string>params;
params["ws.op"]="newComponentUploader"; params["ws.op"]="newComponentUploader";
params["component_name"]=component_name; params["component_name"]=component_name;
@ -779,7 +781,7 @@ std::optional<nlohmann::json> archive::newNamedAuthTokens(const std::vector<std:
} }
std::optional<archive_permission> archive::newPackageUploader(const std::string& person, std::optional<archive_permission> archive::newPackageUploader(const std::string& person,
const std::string& source_package_name) const { const std::string& source_package_name) const {
std::map<std::string,std::string>params; std::map<std::string,std::string>params;
params["ws.op"]="newPackageUploader"; params["ws.op"]="newPackageUploader";
params["person"]=person; params["person"]=person;
@ -807,8 +809,8 @@ std::optional<archive_permission> archive::newPackagesetUploader(const std::stri
} }
std::optional<archive_permission> archive::newPocketQueueAdmin(const std::string& distroseries, std::optional<archive_permission> archive::newPocketQueueAdmin(const std::string& distroseries,
const std::string& person, const std::string& person,
const std::string& pocket) const { const std::string& pocket) const {
std::map<std::string,std::string>params; std::map<std::string,std::string>params;
params["ws.op"]="newPocketQueueAdmin"; params["ws.op"]="newPocketQueueAdmin";
if(!distroseries.empty())params["distroseries"]=distroseries; if(!distroseries.empty())params["distroseries"]=distroseries;
@ -822,7 +824,7 @@ std::optional<archive_permission> archive::newPocketQueueAdmin(const std::string
} }
std::optional<archive_permission> archive::newPocketUploader(const std::string& person, std::optional<archive_permission> archive::newPocketUploader(const std::string& person,
const std::string& pocket) const { const std::string& pocket) const {
std::map<std::string,std::string>params; std::map<std::string,std::string>params;
params["ws.op"]="newPocketUploader"; params["ws.op"]="newPocketUploader";
params["person"]=person; params["person"]=person;
@ -835,7 +837,7 @@ std::optional<archive_permission> archive::newPocketUploader(const std::string&
} }
std::optional<archive_permission> archive::newQueueAdmin(const std::string& component_name, std::optional<archive_permission> archive::newQueueAdmin(const std::string& component_name,
const std::string& person) const { const std::string& person) const {
std::map<std::string,std::string>params; std::map<std::string,std::string>params;
params["ws.op"]="newQueueAdmin"; params["ws.op"]="newQueueAdmin";
params["component_name"]=component_name; params["component_name"]=component_name;

@ -20,6 +20,7 @@
#include "archive_permission.h" #include "archive_permission.h"
#include "binary_package_publishing_history.h" #include "binary_package_publishing_history.h"
#include "archive_dependency.h" #include "archive_dependency.h"
#include "build.h"
#include <generator> #include <generator>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <optional> #include <optional>
@ -36,10 +37,6 @@
class launchpad; class launchpad;
struct build_record {
nlohmann::json data;
};
class archive { class archive {
public: public:
archive(); archive();
@ -102,9 +99,9 @@ public:
bool strict_component = false) const; bool strict_component = false) const;
std::optional<archive_dependency> getArchiveDependency(const std::string& dependency_link) const; std::optional<archive_dependency> getArchiveDependency(const std::string& dependency_link) const;
std::optional<nlohmann::json> getBuildCounters(bool include_needsbuild = false) const; std::optional<nlohmann::json> getBuildCounters(bool include_needsbuild = false) const;
std::generator<build_record> getBuildRecords(const std::string& build_state = "", std::generator<build> getBuildRecords(const std::string& build_state = "",
const std::string& pocket = "", const std::string& pocket = "",
const std::string& source_name = "") const; const std::string& source_name = "") const;
std::optional<nlohmann::json> getBuildSummariesForSourceIds(const std::vector<std::string>& source_ids) const; std::optional<nlohmann::json> getBuildSummariesForSourceIds(const std::vector<std::string>& source_ids) const;
std::generator<archive_permission> getComponentsForQueueAdmin(const std::string& person_link) const; std::generator<archive_permission> getComponentsForQueueAdmin(const std::string& person_link) const;
std::optional<nlohmann::json> getNamedAuthToken(const std::string& name) const; std::optional<nlohmann::json> getNamedAuthToken(const std::string& name) const;

Loading…
Cancel
Save