From 875e1ddeba2f2bd20880fce6166e5efe9bd9e87c Mon Sep 17 00:00:00 2001 From: Michael Baumberger Date: Thu, 26 Dec 2024 15:10:38 +0100 Subject: [PATCH] Refactor Account conversion and fix FIDE ID check. Remove unused `url` field from Account conversion logic and update AccountDto and AccountConverter accordingly. Correct SQL migration to check `fide_id` instead of `platform_id` for adding FIDE accounts. Includes a placeholder for generating `url` in AccountConverter. --- .../kotlin/com/michibaum/chess_service/apis/dtos/AccountDto.kt | 2 +- .../com/michibaum/chess_service/app/account/AccountConverter.kt | 2 +- .../resources/db/migration/V3__move_fide_infos_to_account.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chess-service/src/main/kotlin/com/michibaum/chess_service/apis/dtos/AccountDto.kt b/chess-service/src/main/kotlin/com/michibaum/chess_service/apis/dtos/AccountDto.kt index 8e7667c9..f1e7daa8 100644 --- a/chess-service/src/main/kotlin/com/michibaum/chess_service/apis/dtos/AccountDto.kt +++ b/chess-service/src/main/kotlin/com/michibaum/chess_service/apis/dtos/AccountDto.kt @@ -15,6 +15,6 @@ class AccountDto( val createdAt: LocalDate? = null ) { fun toAccount(id: UUID? = null, games: Set = emptySet()): Account { - return Account(id = id, platformId = this.id, username = username, platform = platform, url = url, name = name, person = null, createdAt = createdAt, games = games) + return Account(id = id, platformId = this.id, username = username, platform = platform, name = name, person = null, createdAt = createdAt, games = games) } } \ No newline at end of file diff --git a/chess-service/src/main/kotlin/com/michibaum/chess_service/app/account/AccountConverter.kt b/chess-service/src/main/kotlin/com/michibaum/chess_service/app/account/AccountConverter.kt index a5da90f2..afd171f0 100644 --- a/chess-service/src/main/kotlin/com/michibaum/chess_service/app/account/AccountConverter.kt +++ b/chess-service/src/main/kotlin/com/michibaum/chess_service/app/account/AccountConverter.kt @@ -11,7 +11,7 @@ class AccountConverter { id = account.idOrThrow(), username = account.username, platform = account.platform, - url = account.url, + url = "", // TODO create url ) } diff --git a/chess-service/src/main/resources/db/migration/V3__move_fide_infos_to_account.sql b/chess-service/src/main/resources/db/migration/V3__move_fide_infos_to_account.sql index 2d8c1c14..4d1159c5 100644 --- a/chess-service/src/main/resources/db/migration/V3__move_fide_infos_to_account.sql +++ b/chess-service/src/main/resources/db/migration/V3__move_fide_infos_to_account.sql @@ -16,7 +16,7 @@ SELECT FROM person p WHERE - p.platform_id IS NOT NULL AND p.platform_id != '' AND -- Check that platform_id is not null and not empty + p.fide_id IS NOT NULL AND p.fide_id != '' AND -- Check that fide_id is not null and not empty NOT EXISTS ( -- Check if the user has already a Fide account SELECT 1 FROM account a