statusweather: Mark some things as const, increase timeout.

This commit is contained in:
tastytea 2021-08-23 18:34:17 +02:00
parent 326d1e75b2
commit 8ef801d1df
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 4 additions and 4 deletions

View File

@ -56,7 +56,7 @@ std::string map_icon(const std::string_view icon_id)
{13, "🌨"},
{50, "🌫"}}};
// TODO: Differenciate between day and night.
auto icon{icons.find(std::stoul(icon_id.data()))};
const auto icon{icons.find(std::stoul(icon_id.data()))};
if (icon != icons.end())
{
return icon->second;
@ -125,7 +125,7 @@ bool fetch_weather()
RestClient::Connection conn(
"http://api.openweathermap.org/data/2.5/weather");
conn.FollowRedirects(true, 5);
conn.SetTimeout(10);
conn.SetTimeout(120);
// <https://openweathermap.org/current>
auto response{
conn.get(format("?appid={0:s}&q={1:s}&units=metric", api_key, city))};
@ -133,7 +133,7 @@ bool fetch_weather()
if (response.code == 200)
{
std::lock_guard<std::mutex> guard(mutex_weather);
const std::lock_guard<std::mutex> guard(mutex_weather);
const auto json{nlohmann::json::parse(response.body)};
weather.temperature = json[0]["main"]["temp"].get<float>();
weather.icon = map_icon(
@ -152,7 +152,7 @@ void print_weather()
{
using fmt::format;
std::lock_guard<std::mutex> guard(mutex_weather);
const std::lock_guard<std::mutex> guard(mutex_weather);
const std::string color{[]
{
if (weather.temperature > 25.0)