Skip to content

Commit

Permalink
Tri des JDDs : null en dernier (#4341)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Nov 26, 2024
1 parent d747439 commit d8249e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/transport/lib/db/dataset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ defmodule DB.Dataset do

@spec order_datasets(Ecto.Query.t(), map()) :: Ecto.Query.t()
def order_datasets(datasets, %{"order_by" => "alpha"}), do: order_by(datasets, asc: :custom_title)
def order_datasets(datasets, %{"order_by" => "most_recent"}), do: order_by(datasets, desc: :inserted_at)
def order_datasets(datasets, %{"order_by" => "most_recent"}), do: order_by(datasets, desc_nulls_last: :inserted_at)

def order_datasets(datasets, %{"q" => q}),
do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ defmodule TransportWeb.DatasetSearchControllerTest do

older_dataset = insert(:dataset, type: type, inserted_at: last_week)
recent_dataset = insert(:dataset, type: type, inserted_at: today)
null_dataset = insert(:dataset, type: type) |> Ecto.Changeset.change(%{inserted_at: nil}) |> DB.Repo.update!()

assert [recent_dataset.id, older_dataset.id] ==
assert [recent_dataset.id, older_dataset.id, null_dataset.id] ==
%{"type" => type, "order_by" => "most_recent"}
|> Dataset.list_datasets()
|> DB.Repo.all()
Expand Down

0 comments on commit d8249e1

Please sign in to comment.