Skip to content

Commit

Permalink
adjust rate limit for download claimable lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jul 7, 2024
1 parent 937ca3e commit 4f01a20
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/managers/BetterInfoCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,25 @@ size_t BetterInfoCache::claimableListsCount() {
void BetterInfoCache::downloadClaimableLists() {
if(m_claimableLists.empty()) return;

size_t listNum = 0;
std::thread([this] {
for(auto [listID, _] : m_claimableLists) {
if(_ != nullptr) continue;

auto searchObj = GJSearchObject::create(SearchType::Search, std::to_string(listID));
ServerUtils::getLevelLists(
searchObj,
[this](auto lists, bool) {
if(lists->empty()) return;
m_claimableLists[lists->at(0)->m_listID] = lists->at(0);
log::debug("Downloaded list {}", lists->at(0)->m_listID);
},
false
);

for(auto [listID, _] : m_claimableLists) {
if(_ != nullptr) continue;

auto searchObj = GJSearchObject::create(SearchType::Search, std::to_string(listID));
ServerUtils::getLevelLists(
searchObj,
[this](auto lists, bool) {
if(lists->empty()) return;
m_claimableLists[lists->at(0)->m_listID] = lists->at(0);
log::debug("Downloaded list {}", lists->at(0)->m_listID);
},
false
);
}
using namespace std::chrono_literals;
std::this_thread::sleep_for(1000ms);
}
}).detach();
}

void BetterInfoCache::showClaimableLists() {
Expand Down

0 comments on commit 4f01a20

Please sign in to comment.