From a1d53b89107122e1f5fb726c46a6293488e8b2eb Mon Sep 17 00:00:00 2001 From: Aurora Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Thu, 26 May 2022 08:17:23 +0300 Subject: [PATCH] Improve SessionEndTransaction to store player name on retry if user_id is missing --- .../database/transactions/events/SessionEndTransaction.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java index 2c0fa7032..34c594c74 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java @@ -16,6 +16,7 @@ */ package com.djrapitops.plan.storage.database.transactions.events; +import com.djrapitops.plan.delivery.domain.PlayerName; import com.djrapitops.plan.exceptions.database.DBOpException; import com.djrapitops.plan.gathering.domain.FinishedSession; import com.djrapitops.plan.gathering.domain.event.JoinAddress; @@ -65,7 +66,10 @@ public class SessionEndTransaction extends Transaction { private void retry(DBOpException failed) { try { UUID playerUUID = session.getPlayerUUID(); - executeOther(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, playerUUID.toString())); + String playerName = session.getExtraData(PlayerName.class) + .map(PlayerName::get) + .orElseGet(playerUUID::toString); + executeOther(new PlayerRegisterTransaction(playerUUID, session::getStart, playerName)); storeSession(); } catch (DBOpException anotherFail) { anotherFail.addSuppressed(failed);