Performance - reduced number of db queries if draft with the same id starts again (ie. after server restart if one was in progress)
This commit is contained in:
@@ -135,6 +135,16 @@ public class CollectionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeFromPlayerCollection(String player, String collectionType, CardCollection cardCollection, String reason) throws SQLException, IOException {
|
||||
_readWriteLock.writeLock().lock();
|
||||
try {
|
||||
removeFromPlayerCollection(_playerDAO.getPlayer(player), collectionType, cardCollection, reason);
|
||||
} finally {
|
||||
_readWriteLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromPlayerCollection(Player player, String collectionType, CardCollection cardCollection, String reason) {
|
||||
if (collectionType.contains("+"))
|
||||
throw new IllegalArgumentException("Invalid collection type: " + collectionType);
|
||||
@@ -308,10 +318,6 @@ public class CollectionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sellCardInPlayerCollection(String player, CollectionType collectionType, String blueprintId, int currency) throws SQLException, IOException {
|
||||
return sellCardInPlayerCollection(_playerDAO.getPlayer(player), collectionType, blueprintId, currency);
|
||||
}
|
||||
|
||||
public boolean sellCardInPlayerCollection(Player player, CollectionType collectionType, String blueprintId, int currency) throws SQLException, IOException {
|
||||
_readWriteLock.writeLock().lock();
|
||||
try {
|
||||
|
||||
@@ -164,11 +164,7 @@ public class TableDraftClassic implements TableDraft{
|
||||
if (draftPlayer instanceof DraftBot) {
|
||||
botCollections.remove(draftPlayer);
|
||||
} else {
|
||||
for (CardCollection.Item item : collection.getAll()) {
|
||||
for (int i = 0; i < item.getCount(); i++) {
|
||||
collectionsManager.sellCardInPlayerCollection(draftPlayer.getName(), collectionType, item.getBlueprintId(), 0);
|
||||
}
|
||||
}
|
||||
collectionsManager.removeFromPlayerCollection(draftPlayer.getName(), collectionType.getCode(), collection, "Duplicate tournament collection");
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException ignore) {
|
||||
|
||||
Reference in New Issue
Block a user