fix weather fetch not running in production

The periodic fetch guard checked !FAPG_DAQ_DB which is true in production (where it points to the real SQLite file). Changed to only skip when FAPG_DAQ_DB is ':memory:' (test mode). Also fixed WeatherFetcher for older Mojolicious compatibility: - Removed chained connect_timeout/request_timeout (not available) - Replaced POSIX::mktime + ENV{TZ} hack with Time::Local::timegm

Commit
a84ac423a04fdc74e422d551d8debaae4e4dd743
Author
GPT-5 medium <codex@openai.com>
Author date
Committer
GPT-5 medium <codex@openai.com>
Committer date
Changed files
roles/dashboard/lib/FAPG/DAQ/Dashboard.pm
index 7493d28e..e6956b8c 100644..100644
@@ -75,8 +75,8 @@
75 75
76 76 $self->helper( weather_fetcher => sub {$weather_fetcher} );
77 77
78 Removed: # Schedule periodic weather fetch (only under a real server, not tests)
79 Removed: if ( $weather_config->{enabled} && !$ENV{FAPG_DAQ_DB} ) {
78 Added: # Schedule periodic weather fetch (skip during tests with in-memory DB)
79 Added: if ( $weather_config->{enabled} && ( $ENV{FAPG_DAQ_DB} // '' ) ne ':memory:' ) {
80 80 require Mojo::IOLoop;
81 81 Mojo::IOLoop->timer(
82 82 5 => sub {
roles/dashboard/lib/FAPG/DAQ/Dashboard/Service/WeatherFetcher.pm
index ca7f4959..00d47d99 100644..100644
@@ -3,12 +3,11 @@
3 3
4 4 use Mojo::UserAgent;
5 5 use Mojo::URL;
6 Removed: use POSIX qw(mktime);
7 Removed: use Scalar::Util qw(looks_like_number);
6 Added: use Time::Local qw(timegm);
8 7
9 8 has 'latitude' => 46.303;
10 9 has 'longitude' => 6.098;
11 Removed: has 'ua' => sub { Mojo::UserAgent->new->connect_timeout(10)->request_timeout(30) };
10 Added: has 'ua' => sub { Mojo::UserAgent->new };
12 11 has 'log' => sub { Mojo::Log->new };
13 12
14 13 use constant BASE_URL => 'https://api.open-meteo.com/v1/meteofrance';
@@ -66,12 +65,7 @@
66 65 return unless $iso && $iso =~ /\A(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/;
67 66
68 67 my ( $year, $mon, $mday, $hour, $min ) = ( $1, $2, $3, $4, $5 );
69 Removed:
70 Removed: # Use timegm equivalent via ENV
71 Removed: local $ENV{TZ} = 'UTC';
72 Removed: POSIX::tzset();
73 Removed: my $epoch = POSIX::mktime( 0, $min, $hour, $mday, $mon - 1, $year - 1900 );
74 Removed: return $epoch;
68 Added: return eval { timegm( 0, $min, $hour, $mday, $mon - 1, $year - 1900 ) };
75 69 }
76 70
77 71 1;