mirror of
https://github.com/KevinMidboe/brewPi.git
synced 2025-10-29 16:50:12 +00:00
27 lines
756 B
TypeScript
27 lines
756 B
TypeScript
import {
|
|
fetchTemperature,
|
|
fetchHumidity,
|
|
fetchPressure
|
|
} from '../../lib/server/graphQueryGenerator';
|
|
import type { PageServerLoad } from './$types';
|
|
import type IChartFrame from '../../lib/interfaces/IChartFrame';
|
|
|
|
const DEFAULT_MINUTES = 10080;
|
|
|
|
export const load: PageServerLoad = async ({ fetch }) => {
|
|
const to = new Date();
|
|
const from = new Date(to.getTime() - DEFAULT_MINUTES * 60 * 1000);
|
|
const size = 40;
|
|
|
|
const temperatureData: IChartFrame[] = await fetchTemperature(from, to, size);
|
|
const humidityData: IChartFrame[] = await fetchHumidity(from, to, size);
|
|
const pressureData: IChartFrame[] = await fetchPressure(from, to, size);
|
|
|
|
return {
|
|
temperatureData,
|
|
humidityData,
|
|
pressureData,
|
|
DEFAULT_MINUTES
|
|
};
|
|
};
|