feat(dashboard): DashboardServiceImpl + KafkaEventConsumer mis à jour
- DashboardServiceImpl : stats enrichies - KafkaEventConsumer : consommation events pour refresh stats temps réel - BackupRecordRepository, SystemLogRepository : petits ajustements
This commit is contained in:
@@ -86,4 +86,18 @@ public class KafkaEventConsumer {
|
||||
LOG.errorf(e, "Failed to broadcast contribution event");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consomme les messages de chat (nouveaux messages envoyés dans une conversation).
|
||||
* Broadcaste l'event en temps réel aux clients WebSocket pour mise à jour instantanée.
|
||||
*/
|
||||
@Incoming("chat-messages-in")
|
||||
public void consumeChatMessages(Record<String, String> record) {
|
||||
LOG.debugf("Received chat message event: key=%s", record.key());
|
||||
try {
|
||||
webSocketBroadcastService.broadcast(record.value());
|
||||
} catch (Exception e) {
|
||||
LOG.errorf(e, "Failed to broadcast chat message event");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,39 @@
|
||||
package dev.lions.unionflow.server.repository;
|
||||
|
||||
import dev.lions.unionflow.server.entity.BackupRecord;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Repository pour les enregistrements de sauvegarde.
|
||||
* Étend BaseRepository pour cohérence avec le reste du projet.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class BackupRecordRepository implements PanacheRepositoryBase<BackupRecord, UUID> {
|
||||
public class BackupRecordRepository extends BaseRepository<BackupRecord> {
|
||||
|
||||
public BackupRecordRepository() {
|
||||
super(BackupRecord.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste tous les enregistrements de sauvegarde triés par date décroissante.
|
||||
*/
|
||||
public List<BackupRecord> findAllOrderedByDate() {
|
||||
return findAll(Sort.by("dateCreation", Sort.Direction.Descending)).list();
|
||||
}
|
||||
|
||||
public void updateStatus(UUID id, String status, Long sizeBytes, LocalDateTime completedAt, String errorMessage) {
|
||||
/**
|
||||
* Met à jour le statut d'un enregistrement de sauvegarde.
|
||||
* Opération transactionnelle — utilisée pour passer de IN_PROGRESS à COMPLETED ou FAILED.
|
||||
*/
|
||||
@Transactional
|
||||
public void updateStatus(UUID id, String status, Long sizeBytes,
|
||||
LocalDateTime completedAt, String errorMessage) {
|
||||
update("status = ?1, sizeBytes = ?2, completedAt = ?3, errorMessage = ?4 WHERE id = ?5",
|
||||
status, sizeBytes, completedAt, errorMessage, id);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Sort;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -150,8 +151,10 @@ public class SystemLogRepository extends BaseRepository<SystemLog> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprimer les logs plus anciens qu'une date donnée (rotation)
|
||||
* Supprimer les logs plus anciens qu'une date donnée (rotation).
|
||||
* Requiert une transaction active — DELETE via JPQL doit être transactionnel.
|
||||
*/
|
||||
@Transactional
|
||||
public int deleteOlderThan(LocalDateTime threshold) {
|
||||
return entityManager.createQuery(
|
||||
"DELETE FROM SystemLog l WHERE l.timestamp < :threshold"
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.quarkus.panache.common.Sort;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -63,6 +64,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
OrganisationRepository organisationRepository;
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public DashboardDataResponse getDashboardData(String organizationId, String userId) {
|
||||
LOG.infof("Récupération des données dashboard pour org: %s et user: %s", organizationId, userId);
|
||||
|
||||
@@ -77,6 +79,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public DashboardStatsResponse getDashboardStats(String organizationId, String userId) {
|
||||
LOG.infof("Récupération des stats dashboard pour org: %s et user: %s", organizationId, userId);
|
||||
|
||||
@@ -171,6 +174,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<RecentActivityResponse> getRecentActivities(String organizationId, String userId, int limit) {
|
||||
LOG.infof("Récupération de %d activités récentes pour org: %s et user: %s", limit, organizationId, userId);
|
||||
|
||||
@@ -253,6 +257,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<UpcomingEventResponse> getUpcomingEvents(String organizationId, String userId, int limit) {
|
||||
LOG.infof("Récupération de %d événements à venir pour org: %s et user: %s", limit, organizationId, userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user