getLatestData hinzugefügt

This commit is contained in:
Tobias Peper 2025-03-22 16:05:23 +01:00
parent 5904b0a451
commit ae7dca5284

View File

@ -34,6 +34,15 @@ class VzRestController {
public VzRestController() { public VzRestController() {
} }
@GetMapping("/rest-vz/latest-data")
List<Aggregate> getLatestData(
@RequestParam("houseId")final int houseId,
@RequestParam("timeWindow")final int timeWindow) {
return jdbcTemplate.query("SELECT * FROM tobias_aggregate2 WHERE houseId=? ORDER BY timestamp_start DESC LIMIT ?;",
(rs, rowNum) -> new Aggregate(houseId, rs.getLong("timestamp_start"), rs.getLong("timestamp_end"), rs.getLong("produced_energy"), rs.getLong("obtained_energy"), rs.getLong("injected_energy")),
houseId, timeWindow);
}
@GetMapping("/rest-vz/sums") @GetMapping("/rest-vz/sums")
Aggregate getData(@RequestParam("timestampStart")final long timestampStart, Aggregate getData(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd, @RequestParam("timestampEnd")final long timestampEnd,