|
|
@ -5,10 +5,15 @@ import app.entities.db.period.PerPeriodStatistic; |
|
|
import app.services.ProfileService; |
|
|
import app.services.ProfileService; |
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
import lombok.Data; |
|
|
import lombok.Data; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
|
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; |
|
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; |
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
@ -21,6 +26,14 @@ public class GraphService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate; |
|
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate; |
|
|
|
|
|
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(GraphService.class); |
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "@hourly") |
|
|
|
|
|
@CacheEvict(value = "graphs", allEntries = true) |
|
|
|
|
|
public void purgeCache() { |
|
|
|
|
|
logger.info("Cache clean"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 2021-03-08 00:00:00.000000 +00:00,3853,srv1 |
|
|
* 2021-03-08 00:00:00.000000 +00:00,3853,srv1 |
|
|
* 2021-03-12 00:00:00.000000 +00:00,930,srv1 |
|
|
* 2021-03-12 00:00:00.000000 +00:00,930,srv1 |
|
|
@ -30,6 +43,7 @@ public class GraphService { |
|
|
* @param searchFilter |
|
|
* @param searchFilter |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Cacheable(value = "graphs", key = "#searchFilter.cacheKey") |
|
|
public List<PerPeriodStatistic> getUsertimeOnPeriod(SearchFilter searchFilter) { |
|
|
public List<PerPeriodStatistic> getUsertimeOnPeriod(SearchFilter searchFilter) { |
|
|
final String sql = "select date_trunc(:delta, timestamp) AS ts, :delta as period, sum(connect_duration) as value, srv_id from user_connections " + |
|
|
final String sql = "select date_trunc(:delta, timestamp) AS ts, :delta as period, sum(connect_duration) as value, srv_id from user_connections " + |
|
|
"where (:account_ids_empty = true or account_id in (:account_ids)) and connect_duration != 0 and timestamp between :begindate and :enddate " + |
|
|
"where (:account_ids_empty = true or account_id in (:account_ids)) and connect_duration != 0 and timestamp between :begindate and :enddate " + |
|
|
@ -60,6 +74,7 @@ public class GraphService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Cacheable(value = "graphs", key = "#searchFilter.cacheKey") |
|
|
public List<VipPerPeriodStatistic> getVipOnPeriod(SearchFilter searchFilter) { |
|
|
public List<VipPerPeriodStatistic> getVipOnPeriod(SearchFilter searchFilter) { |
|
|
final String sql = "select date_trunc(:delta, timestamp) AS ts, :delta as period, count(*) as value, givemethod, amount from gived_vip " + |
|
|
final String sql = "select date_trunc(:delta, timestamp) AS ts, :delta as period, count(*) as value, givemethod, amount from gived_vip " + |
|
|
"where (:account_ids_empty = true or steam2 in (:account_ids)) and givemethod != 4 and timestamp between :begindate and :enddate " + |
|
|
"where (:account_ids_empty = true or steam2 in (:account_ids)) and givemethod != 4 and timestamp between :begindate and :enddate " + |
|
|
|