mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Updated libraries to latest versions and code compatibility fixes;
This commit is contained in:
parent
971a98061d
commit
8cf681dff2
13 changed files with 106 additions and 83 deletions
|
|
@ -9,9 +9,6 @@ import com.j256.ormlite.stmt.SelectArg;
|
|||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.support.DatabaseConnection;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -21,6 +18,10 @@ import org.apache.shiro.crypto.hash.Hash;
|
|||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public enum AuthorizedUserRepository {
|
||||
|
||||
instance;
|
||||
|
|
@ -108,7 +109,7 @@ public enum AuthorizedUserRepository {
|
|||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ import com.j256.ormlite.stmt.SelectArg;
|
|||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.support.DatabaseConnection;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public enum TableRecordRepository {
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ public enum TableRecordRepository {
|
|||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
|||
|
|
@ -94,12 +94,12 @@ public enum UserStatsRepository {
|
|||
|
||||
public long getLatestEndTimeMs() {
|
||||
try {
|
||||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
qb.orderBy("endTimeMs", false).limit(1L);
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
if (!users.isEmpty()) {
|
||||
return users.get(0).getEndTimeMs();
|
||||
}
|
||||
return users.get(0).getEndTimeMs();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(UserStatsRepository.class).error("Error getting the latest end time from DB - ", ex);
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ public enum UserStatsRepository {
|
|||
public List<String> updateUserStats() {
|
||||
Set<String> updatedUsers = new HashSet<>();
|
||||
// Lock the DB so that no other updateUserStats runs at the same time.
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
long latestEndTimeMs = this.getLatestEndTimeMs();
|
||||
List<TableRecord> records = TableRecordRepository.instance.getAfter(latestEndTimeMs);
|
||||
for (TableRecord record : records) {
|
||||
|
|
@ -126,9 +126,9 @@ public enum UserStatsRepository {
|
|||
for (ResultProtos.MatchPlayerProto player : match.getPlayersList()) {
|
||||
UserStats userStats = this.getUser(player.getName());
|
||||
ResultProtos.UserStatsProto proto =
|
||||
userStats != null
|
||||
? userStats.getProto()
|
||||
: ResultProtos.UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||
userStats != null
|
||||
? userStats.getProto()
|
||||
: ResultProtos.UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||
ResultProtos.UserStatsProto.Builder builder = ResultProtos.UserStatsProto.newBuilder(proto)
|
||||
.setMatches(proto.getMatches() + 1);
|
||||
switch (player.getQuit()) {
|
||||
|
|
@ -370,7 +370,7 @@ public enum UserStatsRepository {
|
|||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue