Also try fixing current_series in distribution
This commit is contained in:
parent
dd8f41140f
commit
3bbef476f9
@ -14,6 +14,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "distribution.h"
|
||||
#include "distro_series.h"
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@ -25,15 +26,15 @@ distribution::distribution()
|
||||
summary(""),
|
||||
domain_name(""),
|
||||
lp(nullptr),
|
||||
current_series([this]() -> std::optional<distro_series> {
|
||||
if (current_series_link.empty()) return std::nullopt;
|
||||
current_series([this]() -> std::optional<::distro_series> {
|
||||
if (!lp || current_series_link.empty()) return std::nullopt;
|
||||
if (_current_series) return _current_series;
|
||||
|
||||
auto response = lp ? lp->api_get(current_series_link) : std::nullopt;
|
||||
if (!response) return std::nullopt;
|
||||
|
||||
auto data = nlohmann::json::parse(response.value());
|
||||
auto ds = distro_series::parse(data.dump());
|
||||
auto ds = ::distro_series::parse(data.dump());
|
||||
|
||||
if (ds) {
|
||||
ds->set_lp(lp);
|
||||
|
@ -69,14 +69,15 @@ public:
|
||||
std::string valid_specifications_collection_link;
|
||||
std::string vulnerabilities_collection_link;
|
||||
std::string webhooks_collection_link;
|
||||
|
||||
lazy_optional<distro_series, std::function<std::optional<distro_series>()>> current_series;
|
||||
private:
|
||||
launchpad* lp;
|
||||
std::optional<distro_series> _current_series = std::nullopt;
|
||||
|
||||
// JSON parsing utility
|
||||
void parse_json(const std::string& json_data);
|
||||
|
||||
public:
|
||||
lazy_optional<distro_series, std::function<std::optional<distro_series>()>> current_series;
|
||||
};
|
||||
|
||||
#endif // DISTRIBUTION_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user