master
Tomasz Golinski 2022-07-14 14:47:15 +02:00
rodzic d00a852295
commit 70499296d7
4 zmienionych plików z 53 dodań i 52 usunięć

Wyświetl plik

@ -199,7 +199,7 @@ int main(int argc, char** argv) {
std::unordered_map<int, const Powertrail*> tt_map; // Needed to deduplicate trails
for ( auto& c : tmp ) {
for (auto& c : tmp) {
if (tc.data.count(c.code) > 0) {
c.trail = tc.data[c.code];
t.data[c.trail].found++;
@ -681,7 +681,7 @@ int main(int argc, char** argv) {
}
std::cout << "</table>\n";
/*
/*
n = 1;
std::cout << "<h2>Caches with highest rating</h2>\n";
@ -822,7 +822,7 @@ int main(int argc, char** argv) {
}
}
float perc;
switch(i) {
switch (i) {
case 4:
case 6:
case 9:
@ -872,8 +872,7 @@ int main(int argc, char** argv) {
std::cout << "<td class=\"dt_null\"></td>";
else
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
}
else {
} else {
std::cout << "<td codes=\"" << codes << "\">" << count << "</td>";
n++;
m++;
@ -1114,7 +1113,7 @@ int main(int argc, char** argv) {
}
std::cout << "</table>\n";
/*
/*
n = 1;
std::cout << "<h2>Caches with highest rating</h2>\n";

Wyświetl plik

@ -162,10 +162,14 @@ bool OCdb::update_cache(const json& j) {
fields["type"] = j["data"]["type"].get<std::string>();
if (j["data"].count("status") && !j["data"]["status"].is_null()) {
std::string tmp = j["data"]["status"].get<std::string>();
if (tmp == "Available") fields2["status"] = ok;
else if (tmp == "Archived") fields2["status"] = archived;
else if (tmp == "Temporarily unavailable") fields2["status"] = disabled;
else fields2["status"] = unknown;
if (tmp == "Available")
fields2["status"] = ok;
else if (tmp == "Archived")
fields2["status"] = archived;
else if (tmp == "Temporarily unavailable")
fields2["status"] = disabled;
else
fields2["status"] = unknown;
}
if (j["data"].count("size2") && !j["data"]["size2"].is_null())
fields["size"] = j["data"]["size2"].get<std::string>();
@ -406,8 +410,10 @@ Caches OCdb::parse_sql_caches() const {
//c.country = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 6));
if (sqlite3_column_text(stmt, 7)) c.region = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 7));
if (sqlite3_column_text(stmt, 8)) c.owner_uuid = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 8)); // TODO: we don't know owner's nick
if (sqlite3_column_text(stmt, 9)) c.status = static_cast<Status>(sqlite3_column_int(stmt, 9));
else c.status = unknown;
if (sqlite3_column_text(stmt, 9))
c.status = static_cast<Status>(sqlite3_column_int(stmt, 9));
else
c.status = unknown;
if (sqlite3_column_text(stmt, 10)) c.name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 10));
if (sqlite3_column_text(stmt, 11)) c.country = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 11));

Wyświetl plik

@ -78,7 +78,8 @@ void PowertrailDB::get_trail(uint n) {
T.name = res[1].str();
if (T.name.empty()) return;
Debug(2) << "Read name: " << T.name;
} else return;
} else
return;
if (std::regex_search(curl_output, res, regex_date) && res.size() == 2) {
strptime(res[1].str().c_str(), "%d-%m-%Y", &T.date);
T.date_str = res[1].str();
@ -103,13 +104,13 @@ void PowertrailDB::get_trail(uint n) {
Debug(2) << "Found " << std::distance(caches_begin, caches_end) << " caches.\n";
for (std::sregex_iterator i = caches_begin; i!= caches_end; i++) {
for (std::sregex_iterator i = caches_begin; i != caches_end; i++) {
std::smatch match = *i;
T.caches.insert(match[1].str());
// Debug(2) << match[1].str();
// Debug(2) << match[1].str();
}
data.insert({n, T});
data.insert({ n, T });
}
// Callback for cURL easy interface used to save received output to std::string object
@ -132,7 +133,7 @@ void PowertrailDB::read_from_json(std::string file) {
std::exit(EXIT_FAILURE);
}
for (auto& p: data)
for (auto& p : data)
p.second.number = p.first;
};
@ -143,9 +144,9 @@ void PowertrailDB::save_to_json(std::string file) {
};
Caches_in_Powertrails::Caches_in_Powertrails(PowertrailDB db) {
for ( auto& t : db.data ) {
for ( auto& c : t.second.caches ) {
data.insert( {c, t.second.number} );
for (auto& t : db.data) {
for (auto& c : t.second.caches) {
data.insert({ c, t.second.number });
}
}
}
@ -157,7 +158,6 @@ void Caches_in_Powertrails::read_from_json(std::string file) {
json j;
datafile >> j;
data = j.get<std::unordered_map<std::string, int>>();
// data = j.get<Caches_in_Powertrails>();
}
catch (...) {
Debug(1) << "Cache file: " << file << " corrupted.";
@ -170,6 +170,3 @@ void Caches_in_Powertrails::save_to_json(std::string file) {
json j(data);
datafile << j;
};
// void Caches_in_Powertrails::update_caches(Caches& cc) {
// };

Wyświetl plik

@ -54,11 +54,10 @@ public:
std::unordered_map<std::string, int> data;
Caches_in_Powertrails(PowertrailDB db);
Caches_in_Powertrails() {};
Caches_in_Powertrails(){};
void read_from_json(std::string file);
void save_to_json(std::string file);
// void update_caches(Caches& cc);
private:
};