Browse Source

goty

master
gsd 4 months ago
parent
commit
8b12eec052
  1. 18
      src/main/java/app/controllers/StatsController.java
  2. 18
      src/main/java/app/services/db/DonateService.java

18
src/main/java/app/controllers/StatsController.java

@ -2,8 +2,10 @@ package app.controllers;
import app.annotations.enums.CollectStages;
import app.annotations.interfaces.*;
import app.entities.StatisticRange;
import app.entities.Stats;
import app.services.ExternalServices;
import app.services.db.DonateService;
import app.services.io.readers.ServersReader;
import app.updates.OnlineUpdater;
import app.utils.RealIPService;
@ -30,14 +32,17 @@ public class StatsController {
private HashMap<Map<Integer, String>, HashMap<List<OnlineUpdater.StatsOfPeakOfDay>, Long>> cache = new HashMap<>();
private ServersReader serversReader;
private RealIPService realIPService;
private DonateService donateService;
@Autowired
public StatsController(Stats stats, ExternalServices externalServices, OnlineUpdater onlineUpdater, ServersReader serversReader){
public StatsController(Stats stats, ExternalServices externalServices, OnlineUpdater onlineUpdater, ServersReader serversReader,
DonateService donateService){
this.stats = stats;
this.externalServices = externalServices;
this.onlineUpdater = onlineUpdater;
this.serversReader = serversReader;
this.realIPService = new RealIPService();
this.donateService = donateService;
}
@GetMapping
@ -120,4 +125,15 @@ public class StatsController {
"connect " + route, "steam://connect/" + route
), HttpStatus.OK);
}
@GetMapping("/goty")
@WaitAfterNext(order = "goty")
public Map getGoty() {
//select message, count(*) as c from user_messages group by message order by c desc limit 15 - топ сообщений
//select weapon_name, count(*) as c from user_killfeed group by weapon_name order by c desc limit 10 - топ пушек
//select count(*) as c from user_killfeed where attacker_id != user_killfeed.victim_id - скок умерло карликов
return Map.of(
"topdonate", donateService.getTopSteamSheikh(StatisticRange.YEAR)
);
}
}

18
src/main/java/app/services/db/DonateService.java

@ -7,10 +7,13 @@ import app.entities.VipGiveMethod;
import app.entities.db.DonateStat;
import app.entities.other.SteamID;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;
@ -146,4 +149,19 @@ public class DonateService {
}
//надо добавить шейхов GROUP BY steam2 ORDER BY r DESC
@Data
public static class DonateSheikh {
private String steam2;
private long r;
private long k;
}
public List<DonateSheikh> getTopSteamSheikh(StatisticRange statisticRange) {
return jdbcTemplate.query("SELECT steam2, SUM(CAST(REPLACE(REPLACE(split_part(reserved,';',-2), 'metal=',''), ';','') AS INT)) as r, " +
" SUM(CAST(REPLACE(REPLACE(split_part(reserved,';',1), 'keys=',''), ';','') as INT)) as k " +
"FROM gived_vip WHERE givemethod = ? AND timestamp > date_trunc(?,now())::DATE " +
"group by steam2 order by k desc limit ?",
new Object[]{VipGiveMethod.STEAM.ordinal(), StatisticRange.cast(statisticRange), 10},
new BeanPropertyRowMapper<>(DonateSheikh.class));
}
}

Loading…
Cancel
Save