From 0b187ef20cb25cfba6822574782aa13209ac37f6 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Wed, 3 Feb 2021 18:43:23 +0200 Subject: [PATCH] Removed non-main server plugin data from query results --- .../resolver/json/QueryJSONResolver.java | 7 +++++-- .../ExtensionQueryResultTableDataQuery.java | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java index 57db94f3e..816ac87be 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java @@ -28,6 +28,7 @@ import com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException; import com.djrapitops.plan.delivery.web.resolver.request.Request; import com.djrapitops.plan.delivery.web.resolver.request.WebUser; import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionQueryResultTableDataQuery; +import com.djrapitops.plan.identification.ServerInfo; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.paths.DisplaySettings; import com.djrapitops.plan.settings.config.paths.TimeSettings; @@ -61,6 +62,7 @@ public class QueryJSONResolver implements Resolver { private final PlanConfig config; private final DBSystem dbSystem; + private final ServerInfo serverInfo; private final JSONStorage jsonStorage; private final GraphJSONCreator graphJSONCreator; private final Locale locale; @@ -71,7 +73,7 @@ public class QueryJSONResolver implements Resolver { QueryFilters filters, PlanConfig config, DBSystem dbSystem, - JSONStorage jsonStorage, + ServerInfo serverInfo, JSONStorage jsonStorage, GraphJSONCreator graphJSONCreator, Locale locale, Formatters formatters @@ -79,6 +81,7 @@ public class QueryJSONResolver implements Resolver { this.filters = filters; this.config = config; this.dbSystem = dbSystem; + this.serverInfo = serverInfo; this.jsonStorage = jsonStorage; this.graphJSONCreator = graphJSONCreator; this.locale = locale; @@ -205,7 +208,7 @@ public class QueryJSONResolver implements Resolver { Database database = dbSystem.getDatabase(); return new PlayersTableJSONCreator( database.query(new QueryTablePlayersQuery(playerUUIDs, after, before, config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD))), - database.query(new ExtensionQueryResultTableDataQuery(playerUUIDs)), + database.query(new ExtensionQueryResultTableDataQuery(serverInfo.getServerUUID(), playerUUIDs)), config.get(DisplaySettings.OPEN_PLAYER_LINKS_IN_NEW_TAB), formatters, locale ).toJSONMap(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/ExtensionQueryResultTableDataQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/ExtensionQueryResultTableDataQuery.java index 311ef6a9e..afe54c374 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/ExtensionQueryResultTableDataQuery.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/queries/ExtensionQueryResultTableDataQuery.java @@ -23,7 +23,6 @@ import com.djrapitops.plan.extension.icon.Icon; import com.djrapitops.plan.extension.implementation.results.*; import com.djrapitops.plan.storage.database.SQLDB; import com.djrapitops.plan.storage.database.queries.Query; -import com.djrapitops.plan.storage.database.queries.QueryAllStatement; import com.djrapitops.plan.storage.database.queries.QueryStatement; import com.djrapitops.plan.storage.database.sql.tables.*; import org.apache.commons.text.TextStringBuilder; @@ -48,9 +47,11 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*; */ public class ExtensionQueryResultTableDataQuery implements Query> { + private final UUID serverUUID; private final Collection playerUUIDs; - public ExtensionQueryResultTableDataQuery(Collection playerUUIDs) { + public ExtensionQueryResultTableDataQuery(UUID serverUUID, Collection playerUUIDs) { + this.serverUUID = serverUUID; this.playerUUIDs = playerUUIDs; } @@ -97,13 +98,15 @@ public class ExtensionQueryResultTableDataQuery implements Query>(sql, 1000) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setBoolean(1, true); // Select only values that should be shown statement.setBoolean(2, false); // Don't select player_name String values + statement.setString(3, serverUUID.toString()); } @Override @@ -126,9 +129,15 @@ public class ExtensionQueryResultTableDataQuery implements Query>(sql, 1000) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, serverUUID.toString()); + } - return new QueryAllStatement>(sql, 1000) { @Override public Map processResults(ResultSet set) throws SQLException { return extractDataByPlayer(set);