Browse Source

jdbc migrate clean up fix3

master
gsd 1 year ago
parent
commit
fa9347ed7f
  1. 6
      src/main/java/app/services/db/KillfeedService.java
  2. 4
      src/main/java/app/services/db/UsertimeService.java

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

@ -82,7 +82,7 @@ public class KillfeedService {
}
public Map getKills(SteamID steamID, String server_id, int offset, int limit) {
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`attacker_id` = ? AND u.`attacker_id` != u.`victim_id` AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`attacker_id` = ? AND u.`attacker_id` != u.`victim_id` AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
new Object[]{steamID.account_id, server_id == null || server_id.isEmpty() ? "%" : server_id, limit, offset},
(rs, n) -> new KillsInFeed(rs).setNicknames(nicknameService));
@ -95,7 +95,7 @@ public class KillfeedService {
}
public Map getDeads(SteamID steamID, String server_id, int offset, int limit) {
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`victim_id` = ? AND u.`attacker_id` != u.`victim_id` AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`victim_id` = ? AND u.`attacker_id` != u.`victim_id` AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
new Object[]{steamID.account_id, server_id == null || server_id.isEmpty() ? "%" : server_id, limit, offset},
(rs, n) -> new KillsInFeed(rs).setNicknames(nicknameService));
@ -107,7 +107,7 @@ public class KillfeedService {
}
public Map getAssists(SteamID steamID, String server_id, int offset, int limit) {
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`assister_id` = ? AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
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 INNER JOIN `tf2idb`.`tf2idb_item` as i ON u.`weapon_index` = i.`id` WHERE u.`assister_id` = ? AND u.`server_id` like ? ORDER BY u.`id` DESC LIMIT ? OFFSET ?",
new Object[]{steamID.account_id, server_id == null || server_id.isEmpty() ? "%" : server_id, limit, offset},
(rs, n) -> new KillsInFeed(rs).setNicknames(nicknameService));

4
src/main/java/app/services/db/UsertimeService.java

@ -135,9 +135,9 @@ public class UsertimeService {
public Long getTotalGametimeOnServer(SteamID steamID, String server) {
String db = stats.getServers().entrySet().stream().filter(s -> s.getKey().equals(server)).map(s -> s.getValue().getDb()).findFirst().orElse(null);
if (db == null) return 0L;
return jdbcTemplate.query("SELECT count(id) as c FROM `"+db+"`.`user_connections` WHERE account_id = ? AND connection_type LIKE ?",
return jdbcTemplate.query("SELECT count(id) FROM `"+db+"`.`user_connections` WHERE account_id = ? AND connection_type LIKE ?",
new Object[]{ steamID.account_id, "disconnect" },
(rs, n) -> rs.getLong("с"))
(rs, n) -> rs.getLong(0))
.stream().findFirst().orElse(0L);
}
}

Loading…
Cancel
Save