Revert "do not show deleted wallets (#1942)" (#1947)

This reverts commit 1ee2d53069.
This commit is contained in:
Arc 2023-09-18 19:41:35 +01:00 committed by GitHub
parent b8922a7cd7
commit 3260acbcc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,37 +61,25 @@ async def get_account(
return User(**row) if row else None return User(**row) if row else None
async def get_user( async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[User]:
user_id: str,
conn: Optional[Connection] = None,
include_deleted_wallets: Optional[bool] = False,
) -> Optional[User]:
user = await (conn or db).fetchone( user = await (conn or db).fetchone(
"SELECT id, email FROM accounts WHERE id = ?", (user_id,) "SELECT id, email FROM accounts WHERE id = ?", (user_id,)
) )
if user: if user:
clauses = ["user = ?"]
values: List[Any] = [user_id]
if not include_deleted_wallets:
clauses.append("deleted = ?")
values.append(False)
where = "WHERE " + " AND ".join(clauses) if clauses else ""
extensions = await (conn or db).fetchall( extensions = await (conn or db).fetchall(
"""SELECT extension FROM extensions WHERE "user" = ? AND active""", """SELECT extension FROM extensions WHERE "user" = ? AND active""",
(user_id,), (user_id,),
) )
wallets = await (conn or db).fetchall( wallets = await (conn or db).fetchall(
f""" """
SELECT *, COALESCE(( SELECT *, COALESCE((
SELECT balance FROM balances WHERE wallet = wallets.id SELECT balance FROM balances WHERE wallet = wallets.id
), 0) AS balance_msat ), 0) AS balance_msat
FROM wallets FROM wallets
{where} WHERE "user" = ?
""", """,
tuple(values), (user_id,),
) )
else: else:
return None return None