[Fix] Network page oddities
- Fixed Analysis button being green after a 404 on analysis refresh - Fixed Online graphs going back more than two weeks on servers tab
This commit is contained in:
parent
05bb441b2d
commit
4e36545e0a
|
@ -7,10 +7,14 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.*;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Column;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Select;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -316,15 +320,18 @@ public class TPSTable extends Table {
|
|||
}
|
||||
|
||||
public Map<Integer, List<TPS>> getPlayersOnlineForServers(Collection<Server> servers) {
|
||||
WhereParser sqlParser = Select.from(tableName, Col.SERVER_ID, Col.DATE, Col.PLAYERS_ONLINE)
|
||||
.where(Col.DATE.get() + ">" + (System.currentTimeMillis() - TimeAmount.WEEK.toMillis(2L)));
|
||||
for (Server server : servers) {
|
||||
sqlParser.or(Col.SERVER_ID + "=" + server.getId());
|
||||
}
|
||||
TextStringBuilder sql = new TextStringBuilder("SELECT ");
|
||||
sql.append(Col.SERVER_ID).append(", ")
|
||||
.append(Col.DATE).append(", ")
|
||||
.append(Col.PLAYERS_ONLINE)
|
||||
.append(" FROM ").append(tableName)
|
||||
.append(" WHERE ")
|
||||
.append(Col.DATE.get()).append(">").append(System.currentTimeMillis() - TimeAmount.WEEK.toMillis(2L))
|
||||
.append(" AND (");
|
||||
sql.appendWithSeparators(servers.stream().map(server -> Col.SERVER_ID + "=" + server.getId()).iterator(), " OR ");
|
||||
sql.append(")");
|
||||
|
||||
String sql = sqlParser.toString();
|
||||
|
||||
return query(new QueryAllStatement<Map<Integer, List<TPS>>>(sql, 10000) {
|
||||
return query(new QueryAllStatement<Map<Integer, List<TPS>>>(sql.toString(), 10000) {
|
||||
@Override
|
||||
public Map<Integer, List<TPS>> processResults(ResultSet set) throws SQLException {
|
||||
Map<Integer, List<TPS>> map = new HashMap<>();
|
||||
|
|
|
@ -7,7 +7,6 @@ package com.djrapitops.plan.system.info.request;
|
|||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
|
@ -31,21 +30,22 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
|
||||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final Processors processors;
|
||||
private final HtmlExport htmlExport;
|
||||
|
||||
private final UUID networkUUID;
|
||||
|
||||
private UUID serverUUID;
|
||||
private String html;
|
||||
|
||||
CacheAnalysisPageRequest(
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
Processors processors,
|
||||
HtmlExport htmlExport
|
||||
HtmlExport htmlExport,
|
||||
UUID networkUUID
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.processors = processors;
|
||||
this.networkUUID = networkUUID;
|
||||
this.htmlExport = htmlExport;
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,12 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
UUID serverUUID, String html,
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
Processors processors,
|
||||
HtmlExport htmlExport
|
||||
HtmlExport htmlExport,
|
||||
UUID networkUUID
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.processors = processors;
|
||||
this.networkUUID = networkUUID;
|
||||
this.htmlExport = htmlExport;
|
||||
|
||||
Verify.nullCheck(serverUUID, html);
|
||||
|
@ -82,6 +82,9 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
|
||||
private void cache(UUID serverUUID, String html) {
|
||||
ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html));
|
||||
if (!networkUUID.equals(serverUUID)) {
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(networkUUID));
|
||||
}
|
||||
|
||||
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
|
||||
processing.submitNonCritical(() -> htmlExport.exportServer(serverUUID));
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
|||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
|
@ -29,7 +28,6 @@ public class InfoRequestFactory {
|
|||
private final Lazy<PlanPlugin> plugin;
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final Lazy<Processing> processing;
|
||||
private final Lazy<Processors> processors;
|
||||
private final Lazy<InfoSystem> infoSystem;
|
||||
private final Lazy<ConnectionSystem> connectionSystem;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
|
@ -45,7 +43,6 @@ public class InfoRequestFactory {
|
|||
Lazy<PlanPlugin> plugin,
|
||||
Lazy<PlanConfig> config,
|
||||
Lazy<Processing> processing,
|
||||
Lazy<Processors> processors,
|
||||
Lazy<InfoSystem> infoSystem,
|
||||
Lazy<ConnectionSystem> connectionSystem,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
|
@ -59,7 +56,6 @@ public class InfoRequestFactory {
|
|||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.processors = processors;
|
||||
this.infoSystem = infoSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
|
@ -72,7 +68,7 @@ public class InfoRequestFactory {
|
|||
}
|
||||
|
||||
public CacheRequest cacheAnalysisPageRequest(UUID serverUUID, String html) {
|
||||
return new CacheAnalysisPageRequest(serverUUID, html, config.get(), processing.get(), processors.get(), htmlExport.get());
|
||||
return new CacheAnalysisPageRequest(serverUUID, html, config.get(), processing.get(), htmlExport.get(), serverInfo.get().getServerUUID());
|
||||
}
|
||||
|
||||
public CacheRequest cacheInspectPageRequest(UUID uuid, String html) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
|||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
|
@ -28,7 +27,6 @@ public class InfoRequestHandlerFactory {
|
|||
private final Lazy<PlanPlugin> plugin;
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final Lazy<Processing> processing;
|
||||
private final Lazy<Processors> processors;
|
||||
private final Lazy<InfoSystem> infoSystem;
|
||||
private final Lazy<ConnectionSystem> connectionSystem;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
|
@ -44,7 +42,6 @@ public class InfoRequestHandlerFactory {
|
|||
Lazy<PlanPlugin> plugin,
|
||||
Lazy<PlanConfig> config,
|
||||
Lazy<Processing> processing,
|
||||
Lazy<Processors> processors,
|
||||
Lazy<InfoSystem> infoSystem,
|
||||
Lazy<ConnectionSystem> connectionSystem,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
|
@ -58,7 +55,6 @@ public class InfoRequestHandlerFactory {
|
|||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.processors = processors;
|
||||
this.infoSystem = infoSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
|
@ -71,7 +67,7 @@ public class InfoRequestHandlerFactory {
|
|||
}
|
||||
|
||||
CacheRequest cacheAnalysisPageRequest() {
|
||||
return new CacheAnalysisPageRequest(config.get(), processing.get(), processors.get(), htmlExport.get());
|
||||
return new CacheAnalysisPageRequest(config.get(), processing.get(), htmlExport.get(), serverInfo.get().getServerUUID());
|
||||
}
|
||||
|
||||
CacheRequest cacheInspectPageRequest() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
|||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -48,8 +49,10 @@ public class NetworkServerBox {
|
|||
|
||||
String playersOnlineData = graphs.line().playersOnlineGraph(tpsMutator).toHighChartsSeries();
|
||||
|
||||
boolean isCached = ResponseCache.isCached(PageId.SERVER.of(serverUUID));
|
||||
String cached = isCached ? "Yes" : "No";
|
||||
String pageID = PageId.SERVER.of(serverUUID);
|
||||
boolean isCached = ResponseCache.isCached(pageID);
|
||||
boolean isOnline = isCached && ResponseCache.loadResponse(pageID) instanceof AnalysisPageResponse;
|
||||
String cached = isCached ? (isOnline ? "Yes" : "Offline") : "No";
|
||||
|
||||
return "<div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-6\">" +
|
||||
"<div class=\"card\">" +
|
||||
|
@ -75,7 +78,7 @@ public class NetworkServerBox {
|
|||
"<p><i class=\"fa fa-chart-pie \"></i> Analysis Cached" +
|
||||
"<span class=\"pull-right\"><b>" + cached + "</b></span></p>" +
|
||||
"<a href=\"" + address + "\"><button href=\"" + address + "\" type=\"button\" class=\"pull-right btn bg-" +
|
||||
(isCached ? "light-green" : "grey") +
|
||||
(isCached ? (isOnline ? "light-green" : "deep-orange") : "grey") +
|
||||
" waves-effect\">" +
|
||||
"<i class=\"material-icons\">trending_up</i>" +
|
||||
"<span>ANALYSIS</span>" +
|
||||
|
|
Loading…
Reference in New Issue