Performance - reduced number of active tournament db queries
This commit is contained in:
@@ -1183,7 +1183,6 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
|
||||
|
||||
private void clearCacheInternal() throws SQLException, IOException {
|
||||
_leagueService.clearCache();
|
||||
_tournamentService.clearCache();
|
||||
_cacheManager.clearCaches();
|
||||
_hallServer.cleanup(true);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import com.gempukku.lotro.draft2.SoloDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.DraftPlayer;
|
||||
import com.gempukku.lotro.draft3.TableDraft;
|
||||
import com.gempukku.lotro.draft3.TableDraftDefinitions;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.game.SortAndFilterCards;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import com.gempukku.lotro.league.LeagueService;
|
||||
import com.gempukku.lotro.packs.ProductLibrary;
|
||||
@@ -25,15 +23,10 @@ import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TableDraftRequestHandler extends LotroServerRequestHandler implements UriRequestHandler {
|
||||
|
||||
@@ -268,18 +268,16 @@ public class TableHolder {
|
||||
|
||||
private String getTournamentName(GameTable table) {
|
||||
final League league = table.getGameSettings().league();
|
||||
final Tournament tournament = null; //tournamentService.getLiveTournaments().stream().filter(tournament1 -> tournament1.getTournamentId().equals(table.getGameSettings().tournamentId())).findFirst().orElse(null);
|
||||
if (league != null) {
|
||||
return league.getName() + " - " + table.getGameSettings().leagueSerie().getName();
|
||||
} else if (tournament != null) {
|
||||
String tournamentTableDescription = tournament.getTableDescription();
|
||||
if (tournamentTableDescription == null || tournamentTableDescription.isEmpty()) {
|
||||
return "Casual - " + table.getGameSettings().timeSettings().name();
|
||||
} else if (table.getGameSettings().tournamentId() != null) {
|
||||
final String tournamentTableDescription = tournamentService.getActiveTournamentTableDescription(table.getGameSettings().tournamentId());
|
||||
if (tournamentTableDescription != null) {
|
||||
return tournamentTableDescription;
|
||||
}
|
||||
return tournamentTableDescription;
|
||||
} else {
|
||||
return "Casual - " + table.getGameSettings().timeSettings().name();
|
||||
}
|
||||
|
||||
return "Casual - " + table.getGameSettings().timeSettings().name();
|
||||
}
|
||||
|
||||
public List<GameTable> getTournamentTables(String tournamentId) {
|
||||
|
||||
@@ -179,10 +179,8 @@ public class TournamentService {
|
||||
|
||||
public void reloadTournaments(TableHolder tables) {
|
||||
_tables = tables;
|
||||
clearCache();
|
||||
reloadQueues();
|
||||
|
||||
getLiveTournaments();
|
||||
reloadLiveTournamentsFromDb();
|
||||
}
|
||||
|
||||
public void reloadQueues() {
|
||||
@@ -234,10 +232,6 @@ public class TournamentService {
|
||||
addImmediateRecurringSealed("th_sealed_queue", casual + "Hunters Block Sealed", "thSealedQueue-", "single_th_block_sealed");
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
_activeTournaments.clear();
|
||||
}
|
||||
|
||||
public void cancelAllTournamentQueues() throws SQLException, IOException {
|
||||
for (TournamentQueue tournamentQueue : _tournamentQueues.values())
|
||||
tournamentQueue.leaveAllPlayers();
|
||||
@@ -474,7 +468,9 @@ public class TournamentService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Tournament> getLiveTournaments() {
|
||||
private List<Tournament> reloadLiveTournamentsFromDb() {
|
||||
_activeTournaments.clear();
|
||||
|
||||
List<Tournament> result = new ArrayList<>();
|
||||
for (var dbinfo : _tournamentDao.getUnfinishedTournaments()) {
|
||||
var tournament = upsertTournamentInCache(dbinfo);
|
||||
@@ -483,6 +479,10 @@ public class TournamentService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Tournament> getLiveTournaments() {
|
||||
return new ArrayList<>(_activeTournaments.values());
|
||||
}
|
||||
|
||||
public Tournament getTournamentById(String tournamentId) {
|
||||
Tournament tournament = _activeTournaments.get(tournamentId);
|
||||
if (tournament == null) {
|
||||
@@ -495,6 +495,15 @@ public class TournamentService {
|
||||
return tournament;
|
||||
}
|
||||
|
||||
public String getActiveTournamentTableDescription(String tournamentId) {
|
||||
Tournament tournament = _activeTournaments.get(tournamentId);
|
||||
if (tournament == null) {
|
||||
return null;
|
||||
} else {
|
||||
return tournament.getTableDescription();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized CollectionType getCollectionTypeByCode(String collectionTypeCode) {
|
||||
for (var tourney : getLiveTournaments()) {
|
||||
var collection = tourney.getInfo().Collection;
|
||||
|
||||
Reference in New Issue
Block a user