Daily fixes and loading animations

This commit is contained in:
2026-06-24 11:08:23 -04:00
parent 811780125e
commit 8019dabe2a
4 changed files with 96 additions and 23 deletions

View File

@@ -86,13 +86,12 @@ app.get('/api/daily', async (req, res) => {
const {fields} = req.query;
const start = req.query.start || new Date(new Date().setHours(0, 0, 0, 0)).toISOString();
let now = new Date();
now.setDate(now.getDate() - 1);
now.setHours(0, 0, 0, 0);
now = now.toISOString();
const end = req.query.end || new Date().toISOString();
const coords = await getCoords();
const [sensor, meteo] = await Promise.allSettled([
queryDaily(start, now),
now > start ? queryDaily(start, now) : Promise.resolve([]),
getOpenMeteo(coords.latitude, coords.longitude, now, end),
]);
const history = sensor.status === 'fulfilled' ? sensor.value : [];