Automatische DWD Abfrage
Crontab hinzugefügt und automatische DWD Abfrage jeden Monat eingerichtet.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { APIRoute } from "astro";
|
||||
import moment from "moment";
|
||||
import { ActionFailedError, InvalidDataError, MissingPropertyError, error, success } from "src/lib/APIResponse";
|
||||
import { ActionFailedError, MissingPropertyError, error, success } from "src/lib/APIResponse";
|
||||
import { getClimateFactor } from "src/lib/Klimafaktoren/getClimateFactor";
|
||||
|
||||
export const get: APIRoute = async function({ url }) {
|
||||
@@ -45,11 +45,19 @@ export const get: APIRoute = async function({ url }) {
|
||||
currentDate.add(1, accuracy);
|
||||
}
|
||||
|
||||
const climateFactors = await getClimateFactor(intervals, zip);
|
||||
const klimafaktoren = await getClimateFactor(intervals, zip);
|
||||
|
||||
if (!climateFactors) {
|
||||
if (!klimafaktoren) {
|
||||
return ActionFailedError();
|
||||
}
|
||||
|
||||
return success(climateFactors);
|
||||
if (klimafaktoren.length !== intervals.length) {
|
||||
return error(["Not all dates could be found."]);
|
||||
}
|
||||
|
||||
return success(klimafaktoren.map(klimafaktor => ({
|
||||
month: klimafaktor.month,
|
||||
year: klimafaktor.year,
|
||||
klimafaktor: klimafaktor.klimafaktor,
|
||||
})));
|
||||
}
|
||||
Reference in New Issue
Block a user