feat(documents): add DocumentService.getDensity (#385)

Maps the repository's Object[] rows into a DocumentDensityResult and pairs
them with the archive-wide min/max meta_date range. Read-only, no
@Transactional needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-07 21:50:05 +02:00
parent c90b42d045
commit fbf4725e97
2 changed files with 65 additions and 0 deletions

View File

@@ -125,6 +125,19 @@ public class DocumentService {
return titles;
}
/**
* Per-month document counts for the timeline density widget (issue #385).
* Returns only months that have at least one document — the frontend fills
* gaps using the {@code minDate}/{@code maxDate} bounds.
*/
public DocumentDensityResult getDensity(LocalDate from, LocalDate to) {
List<MonthBucket> buckets = documentRepository.findDensityByMonth(from, to).stream()
.map(row -> new MonthBucket((String) row[0], ((Number) row[1]).intValue()))
.toList();
DocumentDateRangeProjection range = documentRepository.findMinMaxDocumentDate();
return new DocumentDensityResult(buckets, range.getMinDate(), range.getMaxDate());
}
/**
* Lädt eine Datei hoch.
* - Prüft, ob ein Eintrag (aus Excel) schon existiert.