Skip to content

Commit 098cd83

Browse files
committed
feat: add role-based sorting for organization members
1 parent 88bf700 commit 098cd83

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/algora/organizations/organizations.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,17 @@ defmodule Algora.Organizations do
9393
where: m.org_id == ^org.id and m.user_id == u.id,
9494
select_merge: %{
9595
user: u
96-
}
96+
},
97+
order_by: [
98+
fragment(
99+
"CASE WHEN ? = 'admin' THEN 0 WHEN ? = 'mod' THEN 1 WHEN ? = 'expert' THEN 2 ELSE 3 END",
100+
m.role,
101+
m.role,
102+
m.role
103+
),
104+
asc: m.inserted_at,
105+
asc: m.id
106+
]
97107
)
98108
end
99109

0 commit comments

Comments
 (0)