add notification cleanup task
This commit is contained in:
@@ -12,6 +12,7 @@ import SuMoC.backend.trend.dto.TrendDetectionDTO;
|
||||
import SuMoC.backend.trend.services.StatTableUpdateService;
|
||||
import SuMoC.backend.user.models.User;
|
||||
import SuMoC.backend.user.repository.UserRepository;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.google.firebase.messaging.Message;
|
||||
@@ -123,6 +124,27 @@ public class DevController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(description = "Tests the method cleaning old notifications from the database.")
|
||||
@GetMapping("/test-clean-old-notifications")
|
||||
public void testCleanOldNotifications() throws JsonProcessingException, InterruptedException {
|
||||
User user = userRepository.findByEmail("user1@email.com").orElseThrow();
|
||||
|
||||
Notification notification = Notification.builder()
|
||||
.type(NotificationType.TREND)
|
||||
.data(objectMapper.writeValueAsString(TrendDetectionDTO.mockTrendDetectionDTO()))
|
||||
.user(user)
|
||||
.earliestTimeOfDayToSend(LocalTime.now())
|
||||
.createdAt(LocalDateTime.now().minusDays(60))
|
||||
.status(NotificationStatus.SENT)
|
||||
.build();
|
||||
|
||||
notificationRepository.save(notification);
|
||||
|
||||
Thread.sleep(5000);
|
||||
|
||||
scheduledTasks.scheduleCleanUpOldNotifications();
|
||||
}
|
||||
|
||||
@GetMapping("/test-meteo")
|
||||
public void testMeteoClient() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user