mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-18 09:41:02 +02:00
Removed PingTable.Col
This commit is contained in:
parent
a8a871d931
commit
21b1489d69
@ -19,7 +19,6 @@ package com.djrapitops.plan.db.patches;
|
|||||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||||
import com.djrapitops.plan.db.SQLDB;
|
import com.djrapitops.plan.db.SQLDB;
|
||||||
import com.djrapitops.plan.db.sql.tables.PingTable;
|
import com.djrapitops.plan.db.sql.tables.PingTable;
|
||||||
import com.djrapitops.plan.db.sql.tables.PingTable.Col;
|
|
||||||
|
|
||||||
public class PingOptimizationPatch extends Patch {
|
public class PingOptimizationPatch extends Patch {
|
||||||
|
|
||||||
@ -34,8 +33,8 @@ public class PingOptimizationPatch extends Patch {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasBeenApplied() {
|
public boolean hasBeenApplied() {
|
||||||
return hasColumn(tableName, Col.UUID.get())
|
return hasColumn(tableName, PingTable.USER_UUID)
|
||||||
&& hasColumn(tableName, Col.SERVER_UUID.get())
|
&& hasColumn(tableName, PingTable.SERVER_UUID)
|
||||||
&& !hasColumn(tableName, "user_id")
|
&& !hasColumn(tableName, "user_id")
|
||||||
&& !hasColumn(tableName, "server_id")
|
&& !hasColumn(tableName, "server_id")
|
||||||
&& !hasTable(tempTableName); // If this table exists the patch has failed to finish.
|
&& !hasTable(tempTableName); // If this table exists the patch has failed to finish.
|
||||||
@ -48,21 +47,21 @@ public class PingOptimizationPatch extends Patch {
|
|||||||
db.getPingTable().createTable();
|
db.getPingTable().createTable();
|
||||||
|
|
||||||
execute("INSERT INTO " + tableName + " (" +
|
execute("INSERT INTO " + tableName + " (" +
|
||||||
Col.UUID + ", " +
|
PingTable.USER_UUID + ", " +
|
||||||
Col.SERVER_UUID + ", " +
|
PingTable.SERVER_UUID + ", " +
|
||||||
Col.ID + ", " +
|
PingTable.ID + ", " +
|
||||||
Col.MIN_PING + ", " +
|
PingTable.MIN_PING + ", " +
|
||||||
Col.MAX_PING + ", " +
|
PingTable.MAX_PING + ", " +
|
||||||
Col.AVG_PING + ", " +
|
PingTable.AVG_PING + ", " +
|
||||||
Col.DATE +
|
PingTable.DATE +
|
||||||
") SELECT " +
|
") SELECT " +
|
||||||
"(SELECT plan_users.uuid FROM plan_users WHERE plan_users.id = " + tempTableName + ".user_id LIMIT 1), " +
|
"(SELECT plan_users.uuid FROM plan_users WHERE plan_users.id = " + tempTableName + ".user_id LIMIT 1), " +
|
||||||
"(SELECT plan_servers.uuid FROM plan_servers WHERE plan_servers.id = " + tempTableName + ".server_id LIMIT 1), " +
|
"(SELECT plan_servers.uuid FROM plan_servers WHERE plan_servers.id = " + tempTableName + ".server_id LIMIT 1), " +
|
||||||
Col.ID + ", " +
|
PingTable.ID + ", " +
|
||||||
Col.MIN_PING + ", " +
|
PingTable.MIN_PING + ", " +
|
||||||
Col.MAX_PING + ", " +
|
PingTable.MAX_PING + ", " +
|
||||||
Col.AVG_PING + ", " +
|
PingTable.AVG_PING + ", " +
|
||||||
Col.DATE +
|
PingTable.DATE +
|
||||||
" FROM " + tempTableName
|
" FROM " + tempTableName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import com.djrapitops.plan.db.SQLDB;
|
|||||||
import com.djrapitops.plan.db.access.ExecStatement;
|
import com.djrapitops.plan.db.access.ExecStatement;
|
||||||
import com.djrapitops.plan.db.access.QueryStatement;
|
import com.djrapitops.plan.db.access.QueryStatement;
|
||||||
import com.djrapitops.plan.db.patches.PingOptimizationPatch;
|
import com.djrapitops.plan.db.patches.PingOptimizationPatch;
|
||||||
import com.djrapitops.plan.db.sql.parsing.Column;
|
|
||||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
@ -61,12 +60,12 @@ public class PingTable extends UserUUIDTable {
|
|||||||
public PingTable(SQLDB db) {
|
public PingTable(SQLDB db) {
|
||||||
super(TABLE_NAME, db);
|
super(TABLE_NAME, db);
|
||||||
insertStatement = "INSERT INTO " + tableName + " (" +
|
insertStatement = "INSERT INTO " + tableName + " (" +
|
||||||
Col.UUID + ", " +
|
USER_UUID + ", " +
|
||||||
Col.SERVER_UUID + ", " +
|
SERVER_UUID + ", " +
|
||||||
Col.DATE + ", " +
|
DATE + ", " +
|
||||||
Col.MIN_PING + ", " +
|
MIN_PING + ", " +
|
||||||
Col.MAX_PING + ", " +
|
MAX_PING + ", " +
|
||||||
Col.AVG_PING +
|
AVG_PING +
|
||||||
") VALUES (?, ?, ?, ?, ?, ?)";
|
") VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +88,8 @@ public class PingTable extends UserUUIDTable {
|
|||||||
|
|
||||||
public void clean() {
|
public void clean() {
|
||||||
String sql = "DELETE FROM " + tableName +
|
String sql = "DELETE FROM " + tableName +
|
||||||
" WHERE (" + Col.DATE + "<?)" +
|
" WHERE (" + DATE + "<?)" +
|
||||||
" OR (" + Col.MIN_PING + "<0)";
|
" OR (" + MIN_PING + "<0)";
|
||||||
|
|
||||||
execute(new ExecStatement(sql) {
|
execute(new ExecStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
@ -117,7 +116,7 @@ public class PingTable extends UserUUIDTable {
|
|||||||
|
|
||||||
public List<Ping> getPing(UUID uuid) {
|
public List<Ping> getPing(UUID uuid) {
|
||||||
String sql = "SELECT * FROM " + tableName +
|
String sql = "SELECT * FROM " + tableName +
|
||||||
" WHERE " + Col.UUID + "=?";
|
" WHERE " + USER_UUID + "=?";
|
||||||
|
|
||||||
return query(new QueryStatement<List<Ping>>(sql, 10000) {
|
return query(new QueryStatement<List<Ping>>(sql, 10000) {
|
||||||
@Override
|
@Override
|
||||||
@ -131,11 +130,11 @@ public class PingTable extends UserUUIDTable {
|
|||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
pings.add(new Ping(
|
pings.add(new Ping(
|
||||||
set.getLong(Col.DATE.get()),
|
set.getLong(DATE),
|
||||||
UUID.fromString(set.getString(Col.SERVER_UUID.get())),
|
UUID.fromString(set.getString(SERVER_UUID)),
|
||||||
set.getInt(Col.MIN_PING.get()),
|
set.getInt(MIN_PING),
|
||||||
set.getInt(Col.MAX_PING.get()),
|
set.getInt(MAX_PING),
|
||||||
set.getDouble(Col.AVG_PING.get())
|
set.getDouble(AVG_PING)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -171,39 +170,4 @@ public class PingTable extends UserUUIDTable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public enum Col implements Column {
|
|
||||||
@Deprecated
|
|
||||||
ID("id"),
|
|
||||||
@Deprecated
|
|
||||||
UUID(UserUUIDTable.Col.UUID.get()),
|
|
||||||
@Deprecated
|
|
||||||
SERVER_UUID("server_uuid"),
|
|
||||||
@Deprecated
|
|
||||||
DATE("date"),
|
|
||||||
@Deprecated
|
|
||||||
MAX_PING("max_ping"),
|
|
||||||
@Deprecated
|
|
||||||
AVG_PING("avg_ping"),
|
|
||||||
@Deprecated
|
|
||||||
MIN_PING("min_ping");
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
Col(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user