Fixed issue where deleted characters would never go inactive
This commit is contained in:
@@ -142,9 +142,13 @@ impl CharacterRepository {
|
||||
return Ok(characters);
|
||||
}
|
||||
|
||||
// Update the is_active flag
|
||||
let query = "UPDATE character SET \"isActive\" = (\"deletedAt\" IS NULL OR \"deletedAt\" > now()) WHERE \"userId\" = $1";
|
||||
let _ = sqlx::query(query).bind(user_id.clone()).execute(&self.pool).await?;
|
||||
|
||||
// Fetch from database
|
||||
let characters = sqlx::query_as::<_, Character>(
|
||||
"SELECT id, \"userId\" as user_id, name, money, inventory, stats, skills, looks, position, \"createdAt\" as created_at, \"updatedAt\" as updated_at, extract(epoch from (\"deletedAt\" - now()))::BIGINT as deleted_at, \"isActive\" as is_active FROM character WHERE \"userId\" = $1 AND \"isActive\" = true",
|
||||
"SELECT id, \"userId\" as user_id, name, money, inventory, stats, skills, looks, position, \"createdAt\" as created_at, \"updatedAt\" as updated_at, extract(epoch from (\"deletedAt\" - now()))::BIGINT as deleted_at, (\"deletedAt\" IS NULL OR \"deletedAt\" > now()) AS is_active FROM character WHERE \"userId\" = $1 AND \"isActive\" = true",
|
||||
)
|
||||
.bind(user_id)
|
||||
.fetch_all(&self.pool)
|
||||
|
||||
Reference in New Issue
Block a user