mirror of
https://github.com/myronblair/jarvis
synced 2026-07-27 16:22:55 -05:00
Adopt live production state as git baseline
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// Weather endpoint — serves from api_cache (refreshed every 30 min by cron)
|
||||
|
||||
$cached = JarvisDB::query(
|
||||
'SELECT data, UNIX_TIMESTAMP(updated_at) as ts FROM api_cache WHERE cache_key=? LIMIT 1',
|
||||
['weather']
|
||||
);
|
||||
|
||||
if ($cached && !empty($cached[0]['data'])) {
|
||||
$out = json_decode($cached[0]['data'], true);
|
||||
$out['cache_age_s'] = (int)(time() - (int)$cached[0]['ts']);
|
||||
echo json_encode($out);
|
||||
} else {
|
||||
echo json_encode([
|
||||
'current' => null,
|
||||
'forecast' => [],
|
||||
'cache_age_s' => -1,
|
||||
'message' => 'Weather data warming up — available within 5 minutes.',
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user