From 98adf3d87ded27320f73a2d0590e5ad70748e676 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Mon, 24 Mar 2025 12:27:50 -0700 Subject: [PATCH] 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. --- .../lib/internal/fetch/prices/internal/prices/crypto.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/container/src/finance/lib/internal/fetch/prices/internal/prices/crypto.php b/container/src/finance/lib/internal/fetch/prices/internal/prices/crypto.php index e6e7c48..33e93b3 100644 --- a/container/src/finance/lib/internal/fetch/prices/internal/prices/crypto.php +++ b/container/src/finance/lib/internal/fetch/prices/internal/prices/crypto.php @@ -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]; }