Attempt to correct register date when gathering register date data

Affects issues:
- Possibly fixed #2934
This commit is contained in:
Aurora Lahtela 2023-03-26 11:07:42 +03:00
parent e4a32a2902
commit e5cf9cb4c5
2 changed files with 15 additions and 2 deletions

View File

@ -130,8 +130,17 @@ public class PlayerJoinEventConsumer {
.ifPresent(dbSystem.getDatabase()::executeTransaction);
}
private CompletableFuture<?> storeGamePlayer(PlayerJoin join) {
private static long getRegisterDate(PlayerJoin join) {
long registerDate = join.getPlayer().getRegisterDate().orElseGet(join::getTime);
// Correct incorrect register dates https://github.com/plan-player-analytics/Plan/issues/2934
if (registerDate < System.currentTimeMillis() / 1000) {
registerDate = registerDate * 1000;
}
return registerDate;
}
private CompletableFuture<?> storeGamePlayer(PlayerJoin join) {
long registerDate = getRegisterDate(join);
String joinAddress = join.getPlayer().getJoinAddress().orElse(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP);
Transaction transaction = new StoreServerPlayerTransaction(
join.getPlayerUUID(), registerDate, join.getPlayer().getName(), join.getServerUUID(), joinAddress

View File

@ -59,7 +59,11 @@ public class StoreServerPlayerTransaction extends PlayerRegisterTransaction {
// Updates register date to smallest possible value.
Optional<Long> foundRegisterDate = query(PlayerFetchQueries.fetchRegisterDate(playerUUID));
if (foundRegisterDate.isPresent() && foundRegisterDate.get() > registerDate) {
if (foundRegisterDate.isPresent() &&
(foundRegisterDate.get() > registerDate
// Correct incorrect register dates https://github.com/plan-player-analytics/Plan/issues/2934
|| foundRegisterDate.get() < System.currentTimeMillis() / 1000)
) {
execute(DataStoreQueries.updateMainRegisterDate(playerUUID, registerDate));
}