Show current user in users list as well
This commit is contained in:
parent
5b08b470f6
commit
f1a4c3163b
|
@ -779,10 +779,9 @@ def search(term, options \\ %{}) do
|
||||||
Enum.uniq_by(fts_results ++ trigram_results, & &1.id)
|
Enum.uniq_by(fts_results ++ trigram_results, & &1.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_except_one(user, page, page_size) do
|
def all(page, page_size) do
|
||||||
from(
|
from(
|
||||||
u in User,
|
u in User,
|
||||||
where: u.id != ^user.id,
|
|
||||||
limit: ^page_size,
|
limit: ^page_size,
|
||||||
offset: ^((page - 1) * page_size),
|
offset: ^((page - 1) * page_size),
|
||||||
order_by: u.id
|
order_by: u.id
|
||||||
|
|
|
@ -65,7 +65,7 @@ def untag_users(conn, %{"nicknames" => nicknames, "tags" => tags}) do
|
||||||
|
|
||||||
def list_users(%{assigns: %{user: admin}} = conn, %{"page" => page_string}) do
|
def list_users(%{assigns: %{user: admin}} = conn, %{"page" => page_string}) do
|
||||||
with {page, _} <- Integer.parse(page_string),
|
with {page, _} <- Integer.parse(page_string),
|
||||||
users <- User.all_except_one(admin, page, @users_page_size),
|
users <- User.all(page, @users_page_size),
|
||||||
count <- User.count_all_except_one(admin),
|
count <- User.count_all_except_one(admin),
|
||||||
do:
|
do:
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -345,6 +345,11 @@ test "renders users array for the first page" do
|
||||||
"count" => 1,
|
"count" => 1,
|
||||||
"page_size" => 50,
|
"page_size" => 50,
|
||||||
"users" => [
|
"users" => [
|
||||||
|
%{
|
||||||
|
"deactivated" => admin.info.deactivated,
|
||||||
|
"id" => admin.id,
|
||||||
|
"nickname" => admin.nickname
|
||||||
|
},
|
||||||
%{
|
%{
|
||||||
"deactivated" => user.info.deactivated,
|
"deactivated" => user.info.deactivated,
|
||||||
"id" => user.id,
|
"id" => user.id,
|
||||||
|
|
Loading…
Reference in New Issue