diff options
| author | Joel Klinghed <the_jk@opera.com> | 2020-07-17 16:08:26 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@opera.com> | 2020-07-17 16:08:26 +0200 |
| commit | efc0c2cbcdedad5675ba02ef6f4755d030499ffd (patch) | |
| tree | fc33cfa21ec409d37be3309e20d17a736218810b | |
| parent | a1566d1ca182c1714fb5cdb4540adc9afacef5bf (diff) | |
api/taskz?after= is apparently not cummulative
So just write the last state.
| -rw-r--r-- | src/goma.cc | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/goma.cc b/src/goma.cc index 717d7b1..c82920d 100644 --- a/src/goma.cc +++ b/src/goma.cc @@ -8,7 +8,6 @@ #include <rapidjson/error/en.h> #include <string> #include <thread> -#include <unordered_set> #include "args.hh" #include "cairo.hh" @@ -62,8 +61,6 @@ private: std::unique_ptr<CURL, CurlDelete> curl(curl_easy_init()); uint64_t after = 0; - std::unordered_set<uint64_t> active; - std::unordered_set<uint64_t> failed; curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, @@ -81,7 +78,7 @@ private: curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str()); auto ret = curl_easy_perform(curl.get()); if (ret == CURLE_OK) { - parse(content_, &state, &active, &failed, &after); + parse(content_, &state, &after); } else { state.error_ = true; state.msg_ = curl_easy_strerror(ret); @@ -99,11 +96,11 @@ private: } static void parse(std::string const& content, State* state, - std::unordered_set<uint64_t>* active, - std::unordered_set<uint64_t>* failed, uint64_t* after) { *after = 0; state->error_ = false; + state->running_ = 0; + state->failed_ = 0; rapidjson::Document doc; doc.Parse(content.data(), content.size()); @@ -121,45 +118,15 @@ private: if (doc.HasMember("active")) { auto& member = doc["active"]; if (member.IsArray()) { - for (auto& task : member.GetArray()) { - if (task.HasMember("id")) { - auto& id = task["id"]; - if (id.IsUint64()) { - active->insert(id.GetUint64()); - } - } - } + state->running_ = member.Size(); } } if (doc.HasMember("failed")) { auto& member = doc["failed"]; if (member.IsArray()) { - for (auto& task : member.GetArray()) { - if (task.HasMember("id")) { - auto& id = task["id"]; - if (id.IsUint64()) { - failed->insert(id.GetUint64()); - } - } - } + state->failed_ = member.Size(); } } - if (doc.HasMember("finished")) { - auto& member = doc["finished"]; - if (member.IsArray()) { - for (auto& task : member.GetArray()) { - if (task.HasMember("id")) { - auto& id = task["id"]; - if (id.IsUint64()) { - active->erase(id.GetUint64()); - } - } - } - } - } - - state->running_ = active->size(); - state->failed_ = failed->size(); } static size_t write_callback(char* ptr, size_t size, size_t nmemb, |
