This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Show erasure status when listing users in the Admin API #14205
Merged
DMRobertson
merged 15 commits into
matrix-org:develop
from
tadzik:tadzik/show-erased-status-in-admin-user-listing
Oct 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
060d990
Show erasure status when listing users in the Admin API
tadzik 30bd2bf
Use USING when joining erased_users
tadzik 6e602fe
Add changelog entry
tadzik 0906a17
Revert "Use USING when joining erased_users"
tadzik d5919fa
Make the erased check work on postgres
tadzik 960205a
Merge branch 'develop' into tadzik/show-erased-status-in-admin-user-l…
tadzik fe544e7
Add a testcase for showing erased user status
tadzik 5afe378
Appease the style linter
tadzik 795f779
Explicitly convert `erased` to bool to make SQLite consistent with Po…
tadzik 15ac386
Merge branch 'develop' into tadzik/show-erased-status-in-admin-user-l…
tadzik 35c2a88
Move erasure status test to UsersListTestCase
tadzik 84f27cf
Include user erased status when fetching user info via the admin API
tadzik 576bc65
Document the erase status in user_admin_api
tadzik 7aec8d7
Appease the linter and mypy
tadzik 410bae2
Signpost comments in tests
DMRobertson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,7 @@ async def get_users_paginate( | |
name: Optional[str] = None, | ||
guests: bool = True, | ||
deactivated: bool = False, | ||
order_by: str = UserSortOrder.USER_ID.value, | ||
order_by: str = UserSortOrder.NAME.value, | ||
direction: str = "f", | ||
approved: bool = True, | ||
) -> Tuple[List[JsonDict], int]: | ||
|
@@ -261,6 +261,7 @@ def get_users_paginate_txn( | |
sql_base = f""" | ||
FROM users as u | ||
LEFT JOIN profiles AS p ON u.name = '@' || p.user_id || ':' || ? | ||
LEFT JOIN erased_users AS eu ON u.name = eu.user_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a significant impact on performance with an additional left join on a large list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a query plan here: #14205 (comment) There is a sequential scan mentioned under the sorting section, but that mentions the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{where_clause} | ||
""" | ||
sql = "SELECT COUNT(*) as total_users " + sql_base | ||
|
@@ -269,7 +270,8 @@ def get_users_paginate_txn( | |
|
||
sql = f""" | ||
SELECT name, user_type, is_guest, admin, deactivated, shadow_banned, | ||
displayname, avatar_url, creation_ts * 1000 as creation_ts, approved | ||
displayname, avatar_url, creation_ts * 1000 as creation_ts, approved, | ||
eu.user_id not null as erased | ||
DMRobertson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{sql_base} | ||
ORDER BY {order_by_column} {order}, u.name ASC | ||
LIMIT ? OFFSET ? | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.