No need to create a range when total_pages is 0

Fixes:

warning: Range.new/2 and first..last default to a step of -1 when last < first.
Use Range.new(first, last, -1) or first..last//-1, or pass 1 if that was your intention
This commit is contained in:
Claudio Ortolina
2024-12-19 19:02:17 +00:00
parent 129e9e680f
commit 45df749200
@@ -212,7 +212,12 @@ defmodule MusicLibraryWeb.Pagination do
} = pagination_params
total_pages = total_pages(total_entries, page_size)
all_pages = Enum.to_list(1..total_pages)
all_pages =
case total_pages do
0 -> []
other -> Enum.to_list(1..other)
end
{left_pages, middle_pages, right_pages} =
Enum.reduce(all_pages, {[], [], []}, fn p, {left_p, middle_p, right_p} ->