implement client for meteo weather api

This commit is contained in:
2026-01-10 17:53:22 +01:00
parent 1f439338da
commit 4fb5d9c5f8
8 changed files with 191 additions and 3 deletions
@@ -1,5 +1,6 @@
package SuMoC.backend.dev;
import SuMoC.backend.meteo.MeteoClient;
import SuMoC.backend.scheduling.ScheduledTasks;
import SuMoC.backend.trend.services.StatTableUpdateService;
import com.google.firebase.messaging.FirebaseMessaging;
@@ -25,6 +26,8 @@ public class DevController {
private final FirebaseMessaging firebaseMessaging;
private final MeteoClient meteoClient;
@PostMapping("/trigger-trend-calculation")
public void triggerTrendCalculation() {
LocalDate dayOfLastWeek = LocalDate.now().minusDays(7);
@@ -51,4 +54,26 @@ public class DevController {
}
}
@GetMapping("/test-meteo")
public ResponseEntity<String> testMeteoClient() {
try {
// Test with Zurich coordinates
double lat = 47.3769;
double lon = 8.5417;
var forecast = meteoClient.getForecastWeatherCodeToday(lat, lon).block();
if (forecast != null) {
return ResponseEntity.ok("✓ Meteo API working! Received forecast for " +
forecast.latitude() + ", " + forecast.longitude() +
" with " + (forecast.hourly() != null ? forecast.hourly().weatherCode().size() : 0) +
" hourly weather codes");
} else {
return ResponseEntity.status(500).body("✗ No response from Meteo API");
}
} catch (Exception e) {
return ResponseEntity.status(500).body("✗ Failed: " + e.getMessage());
}
}
}