29 lines
812 B
Java
29 lines
812 B
Java
package SuMoC.backend.user.stats;
|
|
|
|
import SuMoC.backend.gamification.Timeframe;
|
|
import SuMoC.backend.user.repository.UserRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class StatsService {
|
|
|
|
@Autowired
|
|
private UserRepository userRepository;
|
|
|
|
@Scheduled(cron = "0 0 0 ? * MON")
|
|
public void resetWeeklyStats() {
|
|
userRepository.findAll().forEach( user -> {
|
|
user.getStats().resetStats(Timeframe.WEEKLY);
|
|
});
|
|
}
|
|
|
|
@Scheduled(cron = "0 0 0 1 * ?")
|
|
public void resetMonthlyStats() {
|
|
userRepository.findAll().forEach( user -> {
|
|
user.getStats().resetStats(Timeframe.MONTHLY);
|
|
});
|
|
}
|
|
}
|