Daily fixes and loading animations
This commit is contained in:
@@ -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 : [];
|
||||
|
||||
Reference in New Issue
Block a user