Bind build::current_source_publication to build::getCurrentSourcePublication()
This commit is contained in:
parent
b7011711b3
commit
b963524519
@ -14,6 +14,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "build.h"
|
||||
#include "source_package_publishing_history.h"
|
||||
#include "utils.h"
|
||||
#include "launchpad.h"
|
||||
#include <iostream>
|
||||
@ -110,3 +111,15 @@ bool build::rescore(int score) {
|
||||
void build::set_lp(launchpad* lp_ptr) {
|
||||
lp = lp_ptr;
|
||||
}
|
||||
|
||||
const std::optional<source_package_publishing_history> build::getCurrentSourcePublication() {
|
||||
auto response = lp->api_get(current_source_publication_link);
|
||||
if (!response) return std::nullopt;
|
||||
auto data = nlohmann::json::parse(response.value());
|
||||
auto sp = source_package_publishing_history::parse(data.dump());
|
||||
if (sp) {
|
||||
sp->set_lp(lp);
|
||||
return sp.value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "source_package_publishing_history.h"
|
||||
|
||||
class launchpad;
|
||||
|
||||
@ -78,8 +79,12 @@ public:
|
||||
std::string datebuilt;
|
||||
std::string datecreated;
|
||||
|
||||
// Object collections
|
||||
std::optional<source_package_publishing_history> current_source_publication = getCurrentSourcePublication();
|
||||
|
||||
private:
|
||||
launchpad* lp;
|
||||
const std::optional<source_package_publishing_history> getCurrentSourcePublication();
|
||||
};
|
||||
|
||||
#endif // BUILD_H
|
||||
|
@ -13,9 +13,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "build.h"
|
||||
#include "source_package_publishing_history.h"
|
||||
#include "utils.h"
|
||||
#include "build.h"
|
||||
#include "launchpad.h"
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <generator>
|
||||
#include "build.h"
|
||||
|
||||
class launchpad;
|
||||
class build;
|
||||
|
||||
#ifndef LAUNCHPAD_API
|
||||
#ifdef BUILDING_LAUNCHPAD
|
||||
|
Loading…
x
Reference in New Issue
Block a user