Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for calculating and loading “Wochentagsdurchschnitt” (weekday average) time-interval data for Dauerzählungen when the frontend selects a Zeitraum-based time selection, plus a few logging/doc/test-context adjustments.
Changes:
- Extend
LadeZaehldatenServicewith a weekday-average extraction path for Dauerzählungen + Zeitraum selection. - Introduce a native-query-based repository method and entity result mapping to fetch weekday averages from
zeitintervall. - Reduce debug logging noise and add a developer doc with SQL scratch queries; adjust Spring test wiring to satisfy new bean dependencies.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/test/java/de/muenchen/dave/domain/mapper/StadtbezirkMapperTest.java |
Adds additional mocked beans to keep the Spring test context bootstrappable with new dependencies. |
src/main/java/de/muenchen/dave/services/persist/ZeitintervallPersistierungsService.java |
Comments out a debug logging loop in aufbereitenForZeitraum. |
src/main/java/de/muenchen/dave/services/ladezaehldaten/LadeZaehldatenService.java |
Adds a new extraction branch + helper method to load weekday averages for Dauerzählungen over a Zeitraum. |
src/main/java/de/muenchen/dave/repositories/relationaldb/ZeitintervallRepository.java |
Adds a repository method intended to execute a native query for weekday averages. |
src/main/java/de/muenchen/dave/domain/Zeitintervall.java |
Adds @NamedNativeQuery + @SqlResultSetMapping and a constructor for mapping weekday-average results. |
src/main/java/de/muenchen/dave/controller/LadeZaehldatenController.java |
Removes debug logging of the full processed payload. |
docs/development.md |
Adds development hints containing SQL statements used to derive the weekday-average query. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+81
| @Query(nativeQuery = true) | ||
| List<Zeitintervall> findWeekdayAverageByZaehlungIdOrderBySortingIndexAsc( | ||
| final String zaehlungId, | ||
| final LocalDateTime start, | ||
| final LocalDateTime ende, | ||
| final List<Integer> vonKnotenarm, | ||
| final List<Integer> nachKnotenarm, | ||
| final List<Integer> tagestyp); |
| List<Integer> vonKnotenarm = IntStream.rangeClosed(1, 8).boxed().toList(); | ||
| List<Integer> nachKnotenarm = IntStream.rangeClosed(1, 8).boxed().toList(); | ||
|
|
||
| if (options.getBeideRichtungen()) { |
| ladeZaehldaten = zeitintervalle.stream() | ||
| .map(zeitintervall -> mapToZaehldatum(zeitintervall, pkwEinheit, options)) | ||
| .collect(Collectors.toList()); | ||
| //ladeZaehldaten = extractZeitintervalleWochentagsdurchschnitt(zaehlungId, options, pkwEinheit); |
Comment on lines
+40
to
+50
| "\tround(sum(pkw)/count(startuhrzeit::time)) as pkw, \n" + // | ||
| "\tround(sum(lkw)/count(startuhrzeit::time)) as lkw,\n" + // | ||
| "\tround(sum (lastzuege)/count(startuhrzeit::time)) as lastzuege,\n" + // | ||
| "\tround(sum(busse)/count(startuhrzeit::time)) as busse,\n" + // | ||
| "\tround(sum(kraftraeder)/count(startuhrzeit::time)) as kraftraeder,\n" + // | ||
| "\tround(sum(fahrradfahrer)/count(startuhrzeit::time)) as fahrradfahrer,\n" + // | ||
| "\tround(sum(fussgaenger)/count(startuhrzeit::time)) as fussgaenger, \n" + // | ||
| "\tround(sum(hochrechnung_hochrechnungkfz)/count(startuhrzeit::time),2) as hochrechnungkfz,\n" + // | ||
| "\tround(sum(hochrechnung_hochrechnunggv)/count(startuhrzeit::time),2) as hochrechnunggv,\n" + // | ||
| "\tround(sum(hochrechnung_hochrechnungsv)/count(startuhrzeit::time),2) as hochrechnungsv,\n" + // | ||
| "\tround(sum(hochrechnungrad)/count(startuhrzeit::time)) as hochrechnungrad,\n" + // |
Comment on lines
+108
to
+111
| //for (Zeitintervall zeitintervall : allZeitintervalle) { | ||
| // log.debug(zeitintervall.getFahrbeziehung() + " " + zeitintervall.getType() + " " + zeitintervall.getStartUhrzeit() + " " | ||
| // + zeitintervall.getEndeUhrzeit() + " " + zeitintervall.getPkw()); | ||
| //} |
Comment on lines
+5
to
+26
| SELECT sum(pkw), count(pkw), max(pkw), startuhrzeit::time FROM public.zeitintervall | ||
| where startuhrzeit between '2026-03-05' and '2026-03-06' | ||
| group by startuhrzeit::time order by startuhrzeit::time ASC limit 300; | ||
|
|
||
| SELECT sum(pkw)/(DATE_PART('day', '2026-03-06'::timestamp - '2026-03-05'::timestamp) + 1), | ||
| startuhrzeit::time | ||
| FROM public.zeitintervall | ||
| where startuhrzeit between '2026-03-05' and '2026-03-07' group by startuhrzeit::time | ||
| order by startuhrzeit::time ASC; | ||
|
|
||
| SELECT pkw, startuhrzeit::time, startuhrzeit::date, | ||
| DATE_PART('day', '2026-03-06'::timestamp - '2026-03-05'::timestamp)+1 FROM public.zeitintervall | ||
| where startuhrzeit between '2026-03-05' and '2026-03-07' | ||
| order by startuhrzeit::time ASC; | ||
|
|
||
| select sum(sumpkw),count(startuhrzeit::time), startuhrzeit::time from ( | ||
| select sum(pkw) as sumpkw, startuhrzeit | ||
| FROM public.zeitintervall | ||
| where startuhrzeit between '2026-03-05' and '2026-03-12' and EXTRACT(DOW FROM startuhrzeit) IN (1, 2, 3, 4, 5) | ||
| and zaehlung_id = '339f992e-0925-4f6d-9e75-099bc520ad2c' group by startuhrzeit) | ||
| group by startuhrzeit::time order by startuhrzeit::time ASC; | ||
|
|
Comment on lines
+337
to
+345
| } else if (zaehlung.getDauerzaehlung() && options.getZeitraum().size() == 2 | ||
| && StringUtils.equals(options.getZeitauswahl(), LadeZaehldatenService.ZEITAUSWAHL_ZEITRAUM)) { | ||
| List<Zeitintervall> zeitintervalle = extractZeitintervalleWochentagsdurchschnitt(zaehlungId, options); | ||
| ladeZaehldaten = zeitintervalle.stream() | ||
| .map(zeitintervall -> mapToZaehldatum(zeitintervall, pkwEinheit, options)) | ||
| .collect(Collectors.toList()); | ||
| //ladeZaehldaten = extractZeitintervalleWochentagsdurchschnitt(zaehlungId, options, pkwEinheit); | ||
| } else { | ||
| List<Zeitintervall> zeitintervalle = extractZeitintervalle(zaehlungId, zaehlung.getZaehldauer(), zaehlung.getKreisverkehr(), options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
If time range is selected, weekday averadge should be shown.
Issue References
Definition of Done