feat(chat): order chats by their names

This is achieved by improving `Ecto.Query` usage.
This commit is contained in:
João Paulo Dubas 2024-10-15 00:44:41 +00:00
parent 7de16a0ea2
commit c6ee2bbf0b
Signed by: joao.dubas
SSH Key Fingerprint: SHA256:V1mixgOGRc/YMhGx/DNkOSmJxgA2vHNrDZEk3wt/kOA

View File

@ -9,8 +9,8 @@ defmodule Slax.Chat do
alias Slax.Repo
def get_first_room! do
query = from(r in Room, limit: 1)
Repo.one(query)
query = from(r in Room, limit: 1, order_by: [asc: :name])
Repo.one!(query)
end
def get_room!(id) do
@ -18,6 +18,7 @@ defmodule Slax.Chat do
end
def list_rooms do
Repo.all(Room)
query = from(r in Room, order_by: [asc: :name])
Repo.all(query)
end
end