|
|
@ -58,12 +58,12 @@ public class StatsController { |
|
|
|
public ResponseEntity<List<OnlineUpdater.StatsOfPeakOfDay>> GetPeakOfDays( |
|
|
|
@RequestParam(required = false, defaultValue = "7") Integer limit, |
|
|
|
@RequestParam(required = false, defaultValue = "%") String server_id) { |
|
|
|
if (limit > 14) return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); |
|
|
|
if (limit > 31) return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); |
|
|
|
|
|
|
|
if (!cache.containsKey(Map.of(limit, server_id))) { |
|
|
|
cache.put(Map.of(limit, server_id), new HashMap<>(){{put(onlineUpdater.getPeakOfDays(server_id, limit), Instant.now().getEpochSecond());}}); |
|
|
|
} |
|
|
|
if (Instant.now().getEpochSecond() - cache.get(Map.of(limit, server_id)).values().stream().findFirst().orElse(0L) < 60L) { |
|
|
|
if (Instant.now().getEpochSecond() - cache.get(Map.of(limit, server_id)).values().stream().findFirst().orElse(0L) > limit * 10) { |
|
|
|
cache.put(Map.of(limit, server_id), new HashMap<>(){{put(onlineUpdater.getPeakOfDays(server_id, limit), Instant.now().getEpochSecond());}}); |
|
|
|
} |
|
|
|
|
|
|
|