|
|
|
@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.boot.context.event.ApplicationReadyEvent; |
|
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
|
import org.springframework.context.event.EventListener; |
|
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
@ -131,7 +132,8 @@ GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ? |
|
|
|
(rs, rowNum) -> new AvgPeakOfDay(rs)); |
|
|
|
} |
|
|
|
|
|
|
|
public List<StatsOfPeakOfPerFiveMinutes> getMaxPeakOfFiveMinutes(String server_id, int limit, Integer minutes) { |
|
|
|
@Cacheable(value = "graphs", key = "#cacheKey") |
|
|
|
public List<StatsOfPeakOfPerFiveMinutes> getMaxPeakOfFiveMinutes(String server_id, int limit, Integer minutes, String cacheKey) { |
|
|
|
long utime = LocalDate.now().minusDays(limit -1).toEpochSecond(LocalTime.MIN, ZoneOffset.ofHours(3)); |
|
|
|
return jdbcTemplate_ro.query("select round(sum(sub.player_count))::int as player_count, sub.ts as fulldate from ("+ |
|
|
|
"SELECT round(avg(player_count), 4) as player_count, date_bin('"+minutes+" minutes'"+",to_timestamp(utime)::timestamp, '2001-01-01 00:02:30') as ts "+ |
|
|
|
@ -145,7 +147,8 @@ GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ? |
|
|
|
(rs, rowNum) -> new StatsOfPeakOfPerFiveMinutes(rs)); |
|
|
|
} |
|
|
|
|
|
|
|
public List<StatsOfPeakOfDay> getPeakOfDays(String server_id, int limit) { |
|
|
|
@Cacheable(value = "graphs", key = "#cacheKey") |
|
|
|
public List<StatsOfPeakOfDay> getPeakOfDays(String server_id, int limit, String cacheKey) { |
|
|
|
List<MaxPeakOfDay> maxPeakOfDays = getMaxPeakOfDays(server_id, limit); |
|
|
|
List<AvgPeakOfDay> avgPeakOfDays = getAvgPeakOfDays(server_id, limit); |
|
|
|
List<StatsOfPeakOfDay> statsOfPeakOfDays = new ArrayList<>(); |
|
|
|
|