diff --git a/src/build.cpp b/src/build.cpp index 401729a..56912eb 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -14,6 +14,7 @@ // along with this program. If not, see . #include "build.h" +#include "source_package_publishing_history.h" #include "utils.h" #include "launchpad.h" #include @@ -110,3 +111,15 @@ bool build::rescore(int score) { void build::set_lp(launchpad* lp_ptr) { lp = lp_ptr; } + +const std::optional 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; +} diff --git a/src/build.h b/src/build.h index 4e0c9ee..25fc2ea 100644 --- a/src/build.h +++ b/src/build.h @@ -19,6 +19,7 @@ #include #include #include +#include "source_package_publishing_history.h" class launchpad; @@ -78,8 +79,12 @@ public: std::string datebuilt; std::string datecreated; + // Object collections + std::optional current_source_publication = getCurrentSourcePublication(); + private: launchpad* lp; + const std::optional getCurrentSourcePublication(); }; #endif // BUILD_H diff --git a/src/source_package_publishing_history.cpp b/src/source_package_publishing_history.cpp index 744cc7c..5d59d06 100644 --- a/src/source_package_publishing_history.cpp +++ b/src/source_package_publishing_history.cpp @@ -13,9 +13,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include "build.h" #include "source_package_publishing_history.h" #include "utils.h" -#include "build.h" #include "launchpad.h" #include #include diff --git a/src/source_package_publishing_history.h b/src/source_package_publishing_history.h index 6093496..cb1d4ab 100644 --- a/src/source_package_publishing_history.h +++ b/src/source_package_publishing_history.h @@ -19,9 +19,9 @@ #include #include #include -#include "build.h" class launchpad; +class build; #ifndef LAUNCHPAD_API #ifdef BUILDING_LAUNCHPAD