Skip to content

Commit 57a5270

Browse files
Hotfix admin dashboard users (#226)
* Hotfix admin dashboard users * last interaction to snake case * Fix
1 parent 2bee78d commit 57a5270

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

controller/user/manager.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ def get_mapped_sorted_paginated_users(
109109
sort_direction: int,
110110
offset: int,
111111
limit: int,
112-
) -> List[Dict[str, str]]:
112+
) -> List[Dict[str, Any]]:
113113

114114
final_users = []
115+
save_len_final_users = 0
115116

116117
# mapping users with the users in kratos
117118
active_users_ids = list(active_users.keys())
@@ -122,22 +123,23 @@ def get_mapped_sorted_paginated_users(
122123
get_user["email"] = get_user["traits"]["email"]
123124
get_user["verified"] = get_user["verifiable_addresses"][0]["verified"]
124125
active_user_by_id = active_users[user_id]
125-
get_user["lastInteraction"] = active_user_by_id["lastInteraction"]
126+
get_user["last_interaction"] = active_user_by_id["last_interaction"]
126127
get_user["role"] = active_user_by_id["role"]
127128
get_user["organization"] = active_user_by_id["organizationName"]
128129

129130
final_users.append(get_user)
131+
save_len_final_users += 1
130132

131133
final_users = sorted(
132134
final_users,
133-
key=lambda x: x[sort_key] if sort_key in x else None,
135+
key=lambda x: (x[sort_key] is None, x.get(sort_key, "")),
134136
reverse=sort_direction == -1,
135137
)
136138

137139
# paginating users
138140
final_users = final_users[offset : offset + limit]
139141

140-
return final_users
142+
return final_users, save_len_final_users
141143

142144

143145
def delete_user(user_id: str) -> None:

fast_api/routes/organization.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def get_mapped_sorted_paginated_users(
340340
active_users = [
341341
{
342342
"id": str(user.id),
343-
"lastInteraction": (
343+
"last_interaction": (
344344
user.last_interaction.isoformat() if user.last_interaction else None
345345
),
346346
"role": user.role,
@@ -356,14 +356,11 @@ def get_mapped_sorted_paginated_users(
356356
]
357357
active_users = {user["id"]: user for user in active_users}
358358

359-
data = user_manager.get_mapped_sorted_paginated_users(
359+
data, final_len = user_manager.get_mapped_sorted_paginated_users(
360360
active_users, body.sort_key, body.sort_direction, body.offset, body.limit
361361
)
362362
return pack_json_result(
363-
{
364-
"mappedSortedPaginatedUsers": data,
365-
"fullCountUsers": len(data),
366-
},
363+
{"mappedSortedPaginatedUsers": data, "fullCountUsers": final_len},
367364
wrap_for_frontend=False, # needed because it's used like this on the frontend (kratos values)
368365
)
369366

0 commit comments

Comments
 (0)