38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package com.example.mindflux.service;
|
|
|
|
import com.example.mindflux.dto.PlatformStatus;
|
|
import com.example.mindflux.repository.GameScoreRepository;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.dao.DataAccessException;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.time.Instant;
|
|
|
|
@Service
|
|
public class PlatformStatusService {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(PlatformStatusService.class);
|
|
private static final int REGISTERED_MODULES = 9;
|
|
|
|
private final GameScoreRepository gameScoreRepository;
|
|
|
|
public PlatformStatusService(GameScoreRepository gameScoreRepository) {
|
|
this.gameScoreRepository = gameScoreRepository;
|
|
}
|
|
|
|
/**
|
|
* Die Abfrage ist absichtlich echt: Nur wenn der Fortschrittsspeicher lesbar
|
|
* ist, meldet das Dashboard das Lernnetz als bereit.
|
|
*/
|
|
public PlatformStatus currentStatus() {
|
|
try {
|
|
gameScoreRepository.count();
|
|
return new PlatformStatus(true, REGISTERED_MODULES, Instant.now());
|
|
} catch (DataAccessException exception) {
|
|
log.warn("Fortschrittsspeicher ist für den Lernnetz-Status nicht erreichbar: {}", exception.getMessage());
|
|
return new PlatformStatus(false, REGISTERED_MODULES, Instant.now());
|
|
}
|
|
}
|
|
}
|