Browse Source

rewrite shits / fix

master
gsd 5 days ago
parent
commit
ae21df1e8e
  1. 52
      src/main/java/app/services/db/KillfeedService.java
  2. 20
      src/main/java/app/services/db/MessageService.java
  3. 20
      src/main/java/app/updates/OnlineUpdater.java

52
src/main/java/app/services/db/KillfeedService.java

@ -37,11 +37,11 @@ public class KillfeedService {
public Long getKills(SteamID steamID, String server_id, Long utime) { public Long getKills(SteamID steamID, String server_id, Long utime) {
return jdbcTemplate.query("SELECT COUNT(*) as c " + return jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND attacker_id = ? AND attacker_id != victim_id AND (? is null or server_id like ?)", "WHERE utime > ? AND attacker_id = ? AND attacker_id != victim_id AND (? = 0 or server_id like ?)",
new Object[]{ new Object[]{
utime==null?0:utime, utime==null?0:utime,
steamID.account_id, steamID.account_id,
server_id==null||server_id.isEmpty()?null:server_id, server_id==null||server_id.isEmpty()?0:1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);
@ -50,11 +50,11 @@ public class KillfeedService {
public List<TopInFeed> getTopKills(String server_id) { public List<TopInFeed> getTopKills(String server_id) {
return jdbcTemplate.query("SELECT attacker_id, count(*) as c, server_id " + return jdbcTemplate.query("SELECT attacker_id, count(*) as c, server_id " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE victim_id != attacker_id AND attacker_id != 0 AND (? is null or server_id LIKE ?) " + "WHERE victim_id != attacker_id AND attacker_id != 0 AND (? =0 or server_id LIKE ?) " +
"GROUP BY attacker_id, server_id " + "GROUP BY attacker_id, server_id " +
"ORDER BY c DESC LIMIT 10", "ORDER BY c DESC LIMIT 10",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id}, server_id == null || server_id.isEmpty() ? "%" : server_id},
(rs, n) -> new TopInFeed(rs).setNicknames(nicknameService)); (rs, n) -> new TopInFeed(rs).setNicknames(nicknameService));
} }
@ -62,11 +62,11 @@ public class KillfeedService {
public Long getDeads(SteamID steamID, String server_id, Long utime) { public Long getDeads(SteamID steamID, String server_id, Long utime) {
return jdbcTemplate.query("SELECT COUNT(*) as c " + return jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND victim_id = ? AND attacker_id != victim_id AND (? is null or server_id like ?)", "WHERE utime > ? AND victim_id = ? AND attacker_id != victim_id AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
utime==null?0:utime, utime==null?0:utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);
@ -75,11 +75,11 @@ public class KillfeedService {
public List<TopInFeed> getTopDeads(String server_id) { public List<TopInFeed> getTopDeads(String server_id) {
return jdbcTemplate.query("SELECT victim_id, count(id) as c, server_id " + return jdbcTemplate.query("SELECT victim_id, count(id) as c, server_id " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE victim_id != attacker_id AND victim_id != 0 AND (? is null or server_id LIKE ?) " + "WHERE victim_id != attacker_id AND victim_id != 0 AND (? =0 or server_id LIKE ?) " +
"GROUP BY victim_id, server_id " + "GROUP BY victim_id, server_id " +
"ORDER BY c DESC LIMIT 10", "ORDER BY c DESC LIMIT 10",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id}, server_id == null || server_id.isEmpty() ? "%" : server_id},
(rs, n) -> new TopInFeed(rs).setNicknames(nicknameService)); (rs, n) -> new TopInFeed(rs).setNicknames(nicknameService));
} }
@ -87,11 +87,11 @@ public class KillfeedService {
public Long getSuicides(SteamID steamID, String server_id, Long utime) { public Long getSuicides(SteamID steamID, String server_id, Long utime) {
return jdbcTemplate.query("SELECT COUNT(*) as c " + return jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND victim_id = ? AND attacker_id = victim_id AND (? is null or server_id like ?)", "WHERE utime > ? AND victim_id = ? AND attacker_id = victim_id AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
utime==null?0:utime, utime==null?0:utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);
@ -100,11 +100,11 @@ public class KillfeedService {
public Long getAssists(SteamID steamID, String server_id, Long utime) { public Long getAssists(SteamID steamID, String server_id, Long utime) {
return jdbcTemplate.query("SELECT COUNT(*) as c " + return jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND assister_id = ? AND (? is null or server_id like ?)", "WHERE utime > ? AND assister_id = ? AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
utime==null?0:utime, utime==null?0:utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id}, server_id==null||server_id.isEmpty()?"%":server_id},
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);
@ -114,12 +114,12 @@ public class KillfeedService {
List<HypeWeapons> result = jdbcTemplate.query("SELECT COUNT(u.weapon_index) as c, i.name, u.server_id, u.weapon_classname " + List<HypeWeapons> result = jdbcTemplate.query("SELECT COUNT(u.weapon_index) as c, i.name, u.server_id, u.weapon_classname " +
"FROM user_killfeed as u " + "FROM user_killfeed as u " +
"INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " + "INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " +
"WHERE u.attacker_id = ? AND attacker_id != victim_id AND (? is null or u.server_id like ?) " + "WHERE u.attacker_id = ? AND attacker_id != victim_id AND (? =0 or u.server_id like ?) " +
"GROUP BY u.weapon_index, i.name, u.server_id, u.weapon_classname " + "GROUP BY u.weapon_index, i.name, u.server_id, u.weapon_classname " +
"ORDER BY c DESC LIMIT ? OFFSET ?", "ORDER BY c DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id, server_id==null||server_id.isEmpty()?"%":server_id,
limit, limit,
offset }, offset },
@ -143,12 +143,12 @@ public class KillfeedService {
List<KillsInFeed> result = jdbcTemplate.query("SELECT -1, u.victim_id, u.assister_id, u.utime, i.name, u.server_id, u.weapon_classname " + List<KillsInFeed> result = jdbcTemplate.query("SELECT -1, u.victim_id, u.assister_id, u.utime, i.name, u.server_id, u.weapon_classname " +
"FROM user_killfeed as u " + "FROM user_killfeed as u " +
"INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " + "INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " +
"WHERE u.utime > ? AND u.attacker_id = ? AND u.attacker_id != u.victim_id AND (? is null or u.server_id like ?) " + "WHERE u.utime > ? AND u.attacker_id = ? AND u.attacker_id != u.victim_id AND (? =0 or u.server_id like ?) " +
"ORDER BY u.id DESC LIMIT ? OFFSET ?", "ORDER BY u.id DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id, server_id == null || server_id.isEmpty() ? "%" : server_id,
limit, limit,
offset}, offset},
@ -156,11 +156,11 @@ public class KillfeedService {
Long count = jdbcTemplate.query("SELECT COUNT(*) as c " + Long count = jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND attacker_id = ? AND attacker_id != victim_id AND (? is null or server_id like ?)", "WHERE utime > ? AND attacker_id = ? AND attacker_id != victim_id AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);
@ -179,12 +179,12 @@ public class KillfeedService {
List<KillsInFeed> result = jdbcTemplate.query("SELECT u.attacker_id, -1, u.assister_id, u.utime, i.name, u.server_id, u.weapon_classname " + List<KillsInFeed> result = jdbcTemplate.query("SELECT u.attacker_id, -1, u.assister_id, u.utime, i.name, u.server_id, u.weapon_classname " +
"FROM user_killfeed as u " + "FROM user_killfeed as u " +
"INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " + "INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " +
"WHERE u.utime > ? AND u.victim_id = ? AND u.attacker_id != u.victim_id AND (? is null or u.server_id like ?) " + "WHERE u.utime > ? AND u.victim_id = ? AND u.attacker_id != u.victim_id AND (? =0 or u.server_id like ?) " +
"ORDER BY u.id DESC LIMIT ? OFFSET ?", "ORDER BY u.id DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id, server_id == null || server_id.isEmpty() ? "%" : server_id,
limit, limit,
offset}, offset},
@ -192,11 +192,11 @@ public class KillfeedService {
Long count = jdbcTemplate.query("SELECT COUNT(*) as c " + Long count = jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND victim_id = ? AND attacker_id != victim_id AND (? is null or server_id like ?)", "WHERE utime > ? AND victim_id = ? AND attacker_id != victim_id AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")).stream().findFirst().orElse(0L); (rs, n) -> rs.getLong("c")).stream().findFirst().orElse(0L);
@ -214,12 +214,12 @@ public class KillfeedService {
List<KillsInFeed> result = jdbcTemplate.query("SELECT u.attacker_id, u.victim_id, -1, u.utime, i.name, u.server_id, u.weapon_classname " + List<KillsInFeed> result = jdbcTemplate.query("SELECT u.attacker_id, u.victim_id, -1, u.utime, i.name, u.server_id, u.weapon_classname " +
"FROM user_killfeed as u " + "FROM user_killfeed as u " +
"INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " + "INNER JOIN tf2idb.tf2idb_item as i ON u.weapon_index = i.id " +
"WHERE u.utime > ? AND u.assister_id = ? AND (? is null or u.server_id like ?) " + "WHERE u.utime > ? AND u.assister_id = ? AND (? =0 or u.server_id like ?) " +
"ORDER BY u.id DESC LIMIT ? OFFSET ?", "ORDER BY u.id DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id, server_id == null || server_id.isEmpty() ? "%" : server_id,
limit, limit,
offset}, offset},
@ -227,11 +227,11 @@ public class KillfeedService {
Long count = jdbcTemplate.query("SELECT COUNT(*) as c " + Long count = jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_killfeed " + "FROM user_killfeed " +
"WHERE utime > ? AND assister_id = ? AND (? is null or server_id like ?)", "WHERE utime > ? AND assister_id = ? AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
current_utime, current_utime,
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);

20
src/main/java/app/services/db/MessageService.java

@ -34,10 +34,10 @@ public class MessageService {
public Map getAllMessages(String server_id, String filter, long offset, int limit) { public Map getAllMessages(String server_id, String filter, long offset, int limit) {
List<Message> result = jdbcTemplate.query("SELECT account_id,utime,message,server_id " + List<Message> result = jdbcTemplate.query("SELECT account_id,utime,message,server_id " +
"FROM user_messages " + "FROM user_messages " +
"WHERE (? is null or server_id like ?) AND message LIKE ? " + "WHERE (? =0 or server_id like ?) AND message LIKE ? " +
"ORDER BY user_messages.id DESC LIMIT ? OFFSET ?", "ORDER BY user_messages.id DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id, server_id == null || server_id.isEmpty() ? "%" : server_id,
filter == null || filter.isEmpty() ? "%" : "%" + filter + "%", filter == null || filter.isEmpty() ? "%" : "%" + filter + "%",
limit, limit,
@ -46,9 +46,9 @@ public class MessageService {
Long count = jdbcTemplate.query("SELECT COUNT(*) as c " + Long count = jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_messages " + "FROM user_messages " +
"WHERE (? is null or server_id like ?) AND message LIKE ?", "WHERE (? =0 or server_id like ?) AND message LIKE ?",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id, server_id==null||server_id.isEmpty()?"%":server_id,
filter==null||filter.isEmpty()?"%":"%" + filter + "%" }, filter==null||filter.isEmpty()?"%":"%" + filter + "%" },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
@ -60,11 +60,11 @@ public class MessageService {
public Map getAccountMessages(SteamID steamID, String server_id, String filter, int offset, int limit) { public Map getAccountMessages(SteamID steamID, String server_id, String filter, int offset, int limit) {
List<Message> result = jdbcTemplate.query("SELECT account_id,utime,message,server_id " + List<Message> result = jdbcTemplate.query("SELECT account_id,utime,message,server_id " +
"FROM user_messages " + "FROM user_messages " +
"WHERE account_id = ? AND (? is null or server_id like ?) AND message LIKE ? " + "WHERE account_id = ? AND (? =0 or server_id like ?) AND message LIKE ? " +
"ORDER BY user_messages.id DESC LIMIT ? OFFSET ?", "ORDER BY user_messages.id DESC LIMIT ? OFFSET ?",
new Object[]{ new Object[]{
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id == null || server_id.isEmpty() ? "%" : server_id, server_id == null || server_id.isEmpty() ? "%" : server_id,
filter == null || filter.isEmpty() ? "%" : "%" + filter + "%", filter == null || filter.isEmpty() ? "%" : "%" + filter + "%",
limit, limit,
@ -73,10 +73,10 @@ public class MessageService {
Long count = jdbcTemplate.query("SELECT COUNT(*) as c " + Long count = jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_messages " + "FROM user_messages " +
"WHERE account_id = ? AND (? is null or server_id like ?) AND message LIKE ?", "WHERE account_id = ? AND (? =0 or server_id like ?) AND message LIKE ?",
new Object[]{ new Object[]{
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id, server_id==null||server_id.isEmpty()?"%":server_id,
filter==null||filter.isEmpty()?"%":"%" + filter + "%"}, filter==null||filter.isEmpty()?"%":"%" + filter + "%"},
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
@ -88,10 +88,10 @@ public class MessageService {
public Long getMessageCount(SteamID steamID, String server_id) { public Long getMessageCount(SteamID steamID, String server_id) {
return jdbcTemplate.query("SELECT COUNT(*) as c " + return jdbcTemplate.query("SELECT COUNT(*) as c " +
"FROM user_messages " + "FROM user_messages " +
"WHERE account_id = ? AND (? is null or server_id like ?)", "WHERE account_id = ? AND (? =0 or server_id like ?)",
new Object[]{ new Object[]{
steamID.account_id, steamID.account_id,
server_id == null || server_id.isEmpty() ? null : server_id, server_id == null || server_id.isEmpty() ? 0 : 1,
server_id==null||server_id.isEmpty()?"%":server_id }, server_id==null||server_id.isEmpty()?"%":server_id },
(rs, n) -> rs.getLong("c")) (rs, n) -> rs.getLong("c"))
.stream().findFirst().orElse(0L); .stream().findFirst().orElse(0L);

20
src/main/java/app/updates/OnlineUpdater.java

@ -68,10 +68,10 @@ public class OnlineUpdater extends BaseUpdater {
//todo abstract on all //todo abstract on all
public List<PerDayStats> getStatsOnPerDay(String server_id) { public List<PerDayStats> getStatsOnPerDay(String server_id) {
return jdbcTemplate_ro.query("SELECT avg(player_count) as player_count, cast(to_timestamp(utime) as date) as fulldate, utime as ts " + return jdbcTemplate_ro.query("SELECT avg(player_count) as player_count, cast(to_timestamp(utime) as date) as fulldate, utime as ts " +
"FROM servers_online WHERE player_count != 0 and (? is null or server_id like ?) " + "FROM servers_online WHERE player_count != 0 and (? =0 or server_id like ?) " +
"GROUP BY cast(to_timestamp(utime) as date) / ? ORDER BY ts ASC", "GROUP BY cast(to_timestamp(utime) as date) / ? ORDER BY ts ASC",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null: server_id, server_id == null || server_id.isEmpty() ? 0: 1,
server_id == null || server_id.isEmpty() ? "%": server_id, server_id == null || server_id.isEmpty() ? "%": server_id,
PerDayStats.period}, PerDayStats.period},
(rs, rowNum) -> new PerDayStats(rs)); (rs, rowNum) -> new PerDayStats(rs));
@ -79,10 +79,10 @@ public class OnlineUpdater extends BaseUpdater {
public List<PerFiveMinutesStats> getStatsOnPerFiveMinutes(String server_id) { public List<PerFiveMinutesStats> getStatsOnPerFiveMinutes(String server_id) {
return jdbcTemplate_ro.query("SELECT avg(player_count) as player_count, cast(to_timestamp(utime) as date) as fulldate, utime as ts " + return jdbcTemplate_ro.query("SELECT avg(player_count) as player_count, cast(to_timestamp(utime) as date) as fulldate, utime as ts " +
"FROM servers_online WHERE player_count != 0 and (? is null or server_id like ?) " + "FROM servers_online WHERE player_count != 0 and (? =0 or server_id like ?) " +
"GROUP BY cast(to_timestamp(utime) as date) / ? ORDER BY ts ASC", "GROUP BY cast(to_timestamp(utime) as date) / ? ORDER BY ts ASC",
new Object[]{ new Object[]{
server_id == null || server_id.isEmpty() ? null: server_id, server_id == null || server_id.isEmpty() ? 0: 1,
server_id == null || server_id.isEmpty() ? "%": server_id, server_id == null || server_id.isEmpty() ? "%": server_id,
PerFiveMinutesStats.period}, PerFiveMinutesStats.period},
(rs, rowNum) -> new PerFiveMinutesStats(rs)); (rs, rowNum) -> new PerFiveMinutesStats(rs));
@ -104,11 +104,11 @@ public class OnlineUpdater extends BaseUpdater {
SELECT round(sum(s.player_count))::int as player_count, s.ts as fl FROM ( SELECT round(sum(s.player_count))::int as player_count, s.ts as fl FROM (
SELECT round(max(player_count), 4) as player_count, to_timestamp(utime)::date as ts SELECT round(max(player_count), 4) as player_count, to_timestamp(utime)::date as ts
FROM servers_online FROM servers_online
WHERE (? is null or server_id like ?) and player_count != 0 WHERE (? = 0 or server_id like ?) and player_count != 0
GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ? GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ?
""", """,
new Object[]{ new Object[]{
server_id==null||server_id.isEmpty()?null:server_id, server_id==null||server_id.isEmpty()?0:1,
server_id==null||server_id.isEmpty()?"%":server_id, server_id==null||server_id.isEmpty()?"%":server_id,
limit}, limit},
(rs, rowNum) -> new MaxPeakOfDay(rs)); (rs, rowNum) -> new MaxPeakOfDay(rs));
@ -119,11 +119,11 @@ GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ?
SELECT round(sum(s.player_count))::int as player_count, s.ts as fl FROM ( SELECT round(sum(s.player_count))::int as player_count, s.ts as fl FROM (
SELECT round(avg(player_count), 4) as player_count, to_timestamp(utime)::date as ts SELECT round(avg(player_count), 4) as player_count, to_timestamp(utime)::date as ts
FROM servers_online FROM servers_online
WHERE (? is null or server_id like ?) and player_count != 0 WHERE (? = 0 or server_id like ?) and player_count != 0
GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ? GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ?
""", """,
new Object[]{ new Object[]{
server_id==null||server_id.isEmpty()?null:server_id, server_id==null||server_id.isEmpty()?0:1,
server_id==null||server_id.isEmpty()?"%":server_id, server_id==null||server_id.isEmpty()?"%":server_id,
limit}, limit},
(rs, rowNum) -> new AvgPeakOfDay(rs)); (rs, rowNum) -> new AvgPeakOfDay(rs));
@ -134,11 +134,11 @@ GROUP BY ts, server_id) as s group by s.ts order by s.ts desc limit ?
return jdbcTemplate_ro.query("select round(sum(sub.player_count))::int as player_count, sub.ts as fulldate from ("+ 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 "+ "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 "+
"FROM servers_online " + "FROM servers_online " +
"WHERE utime >= ? and (? is null or server_id like ?) "+ "WHERE utime >= ? and (? = 0 or server_id like ?) "+
"GROUP BY ts, server_id) sub GROUP BY sub.ts ", "GROUP BY ts, server_id) sub GROUP BY sub.ts ",
new Object[]{ new Object[]{
utime, utime,
server_id==null||server_id.isEmpty()?null:server_id, server_id==null||server_id.isEmpty()?0:1,
server_id==null||server_id.isEmpty()?"%":server_id}, server_id==null||server_id.isEmpty()?"%":server_id},
(rs, rowNum) -> new StatsOfPeakOfPerFiveMinutes(rs)); (rs, rowNum) -> new StatsOfPeakOfPerFiveMinutes(rs));
} }

Loading…
Cancel
Save