container: fetch: prices: crypto: mobula: isolate given year

- Will now only parse given year (or 'all', if given).

  * No longer parses all subsequent years after given year
    (unless 'all' is given).

- Now prints most recent daily average for given year instead of most
  recent daily average for current year.
This commit is contained in:
2025-03-24 12:27:50 -07:00
parent a61668dcb1
commit 98adf3d87d

View File

@@ -200,8 +200,15 @@ namespace docker_finance\prices\internal\prices\crypto
$timestamp = $prices[$i][0] / 1000;
$date = date('Y/m/d', $timestamp);
$price = $prices[$i][1];
// Isolate given year
$given_year = $this->get_env()->get_env('API_FETCH_YEAR');
if ($given_year != 'all' && !preg_match('/^'.$given_year.'\//', $date)) {
utils\CLI::print_debug("skipping $date");
continue;
}
$price = $prices[$i][1];
$stack += [$date => $price];
}