AdminStatisticsService korrigiert: Proben werden jetzt basierend auf ownerAccountId und createdByUserCode korrekt zugeordnet
This commit is contained in:
@@ -31,11 +31,24 @@ public class AdminStatisticsService {
|
|||||||
// Alle Proben laden
|
// Alle Proben laden
|
||||||
List<Sample> allSamples = sampleRepository.findAll();
|
List<Sample> allSamples = sampleRepository.findAll();
|
||||||
|
|
||||||
// Proben pro Tierarzt zählen (basierend auf createdByUserCode)
|
// Proben pro Tierarzt zählen (basierend auf ownerAccountId oder createdByUserCode)
|
||||||
List<AdminStatistics.VetSampleStats> samplesPerVet = vets.stream()
|
List<AdminStatistics.VetSampleStats> samplesPerVet = vets.stream()
|
||||||
.map(vet -> {
|
.map(vet -> {
|
||||||
|
String vetId = vet.id();
|
||||||
|
String accountId = vet.accountId();
|
||||||
|
|
||||||
long sampleCount = allSamples.stream()
|
long sampleCount = allSamples.stream()
|
||||||
.filter(s -> vet.id().equals(s.createdByUserCode()))
|
.filter(s -> {
|
||||||
|
// Prüfe sowohl ownerAccountId als auch createdByUserCode
|
||||||
|
String ownerId = s.ownerAccountId();
|
||||||
|
String creatorId = s.createdByUserCode();
|
||||||
|
|
||||||
|
// Vergleiche mit vet.id() oder vet.accountId()
|
||||||
|
return vetId.equals(ownerId) ||
|
||||||
|
vetId.equals(creatorId) ||
|
||||||
|
accountId != null && accountId.equals(ownerId) ||
|
||||||
|
accountId != null && accountId.equals(creatorId);
|
||||||
|
})
|
||||||
.count();
|
.count();
|
||||||
return new AdminStatistics.VetSampleStats(
|
return new AdminStatistics.VetSampleStats(
|
||||||
vet.id(),
|
vet.id(),
|
||||||
|
|||||||
Reference in New Issue
Block a user