feat(dashboard): expose findContributorsPerDocument in AuditLogQueryService
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package org.raddatz.familienarchiv.dashboard;
|
||||
|
||||
import org.raddatz.familienarchiv.audit.AuditLogRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AuditLogQueryService {
|
||||
|
||||
private final AuditLogQueryRepository queryRepository;
|
||||
|
||||
public AuditLogQueryService(AuditLogQueryRepository queryRepository) {
|
||||
this.queryRepository = queryRepository;
|
||||
}
|
||||
|
||||
public Optional<UUID> findMostRecentDocumentForUser(UUID userId) {
|
||||
return queryRepository.findMostRecentDocumentIdByActor(userId);
|
||||
}
|
||||
|
||||
public List<ActivityFeedRow> findActivityFeed(UUID currentUserId, int limit) {
|
||||
return queryRepository.findDedupedActivityFeed(currentUserId.toString(), limit);
|
||||
}
|
||||
|
||||
public PulseStatsRow getPulseStats(OffsetDateTime weekStart, UUID userId) {
|
||||
return queryRepository.getPulseStats(weekStart, userId.toString());
|
||||
}
|
||||
|
||||
public Map<UUID, UUID> findMostRecentActorPerDocument(List<UUID> documentIds, String kind) {
|
||||
if (documentIds.isEmpty()) return Map.of();
|
||||
List<Object[]> rows = queryRepository.findMostRecentActorPerDocument(documentIds, kind);
|
||||
Map<UUID, UUID> result = new LinkedHashMap<>();
|
||||
for (Object[] row : rows) {
|
||||
UUID docId = (UUID) row[0];
|
||||
UUID actorId = (UUID) row[1];
|
||||
result.put(docId, actorId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<UUID, List<ActivityActorDTO>> findContributorsPerDocument(List<UUID> documentIds) {
|
||||
if (documentIds.isEmpty()) return Map.of();
|
||||
List<ContributorRow> rows = queryRepository.findContributorsPerDocument(documentIds);
|
||||
Map<UUID, List<ActivityActorDTO>> result = new LinkedHashMap<>();
|
||||
for (ContributorRow row : rows) {
|
||||
result.computeIfAbsent(row.getDocumentId(), k -> new ArrayList<>())
|
||||
.add(new ActivityActorDTO(row.getActorInitials(), row.getActorColor(), row.getActorName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user