Decrease visible records per page
After months of usage, I rarely paginate the list, so it's not necessary to load 100 at a time. 20 is enough. By matching 20 records with a 20 pool size, we should keep the repo queue time to a minimum.
This commit is contained in:
@@ -14,7 +14,7 @@ DATABASE_PATH = '/mnt/music_library/music_library_prod.db'
|
|||||||
PHX_HOST = 'music-library.claudio-ortolina.org'
|
PHX_HOST = 'music-library.claudio-ortolina.org'
|
||||||
PORT = '8080'
|
PORT = '8080'
|
||||||
LAST_FM_USER = 'cloud8421'
|
LAST_FM_USER = 'cloud8421'
|
||||||
POOL_SIZE = '10'
|
POOL_SIZE = '20'
|
||||||
|
|
||||||
[[mounts]]
|
[[mounts]]
|
||||||
source = 'music_library'
|
source = 'music_library'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
|||||||
@default_records_list_params %{
|
@default_records_list_params %{
|
||||||
query: "",
|
query: "",
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 100
|
page_size: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
|||||||
@default_records_list_params %{
|
@default_records_list_params %{
|
||||||
query: "",
|
query: "",
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 100
|
page_size: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
|||||||
|
|
||||||
setup :verify_on_exit!
|
setup :verify_on_exit!
|
||||||
|
|
||||||
@default_records_page_size 100
|
@default_records_page_size 20
|
||||||
@total_records @default_records_page_size + 10
|
@total_records @default_records_page_size + 10
|
||||||
|
|
||||||
defp fill_collection(_) do
|
defp fill_collection(_) do
|
||||||
@@ -81,39 +81,35 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
|||||||
setup [:fill_collection]
|
setup [:fill_collection]
|
||||||
|
|
||||||
test "uses query string params", %{conn: conn, collection: records} do
|
test "uses query string params", %{conn: conn, collection: records} do
|
||||||
{:ok, page_2_live, page_2_html} = live(conn, ~p"/collection?page=2&page_size=25")
|
{:ok, page_2_live, page_2_html} = live(conn, ~p"/collection?page=2&page_size=10")
|
||||||
|
|
||||||
{page_2_present, page_2_absent} =
|
{page_2_present, page_2_absent} =
|
||||||
Enum.split_with(records, fn record ->
|
Enum.split_with(records, fn record ->
|
||||||
page_2_html =~ record.id
|
page_2_html =~ record.id
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert length(page_2_present) == 25
|
assert length(page_2_present) == 10
|
||||||
assert length(page_2_absent) == @total_records - 25
|
assert length(page_2_absent) == @total_records - 10
|
||||||
|
|
||||||
page_2_pagination = page_2_live |> with_target("#pagination")
|
page_2_pagination = page_2_live |> with_target("#pagination")
|
||||||
refute has_element?(page_2_pagination, "a", "2")
|
refute has_element?(page_2_pagination, "a", "2")
|
||||||
assert has_element?(page_2_pagination, "a", "1")
|
assert has_element?(page_2_pagination, "a", "1")
|
||||||
assert has_element?(page_2_pagination, "a", "3")
|
assert has_element?(page_2_pagination, "a", "3")
|
||||||
assert has_element?(page_2_pagination, "a", "4")
|
|
||||||
assert has_element?(page_2_pagination, "a", "5")
|
|
||||||
|
|
||||||
{:ok, page_3_live, page_3_html} = live(conn, ~p"/collection?page=3&page_size=25")
|
{:ok, page_3_live, page_3_html} = live(conn, ~p"/collection?page=3&page_size=10")
|
||||||
|
|
||||||
{page_3_present, page_3_absent} =
|
{page_3_present, page_3_absent} =
|
||||||
Enum.split_with(records, fn record ->
|
Enum.split_with(records, fn record ->
|
||||||
page_3_html =~ record.id
|
page_3_html =~ record.id
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert length(page_3_present) == 25
|
assert length(page_3_present) == 10
|
||||||
assert length(page_3_absent) == @total_records - 25
|
assert length(page_3_absent) == @total_records - 10
|
||||||
|
|
||||||
page_3_pagination = page_3_live |> with_target("#pagination")
|
page_3_pagination = page_3_live |> with_target("#pagination")
|
||||||
refute has_element?(page_3_pagination, "a", "3")
|
refute has_element?(page_3_pagination, "a", "3")
|
||||||
assert has_element?(page_3_pagination, "a", "1")
|
assert has_element?(page_3_pagination, "a", "1")
|
||||||
assert has_element?(page_3_pagination, "a", "2")
|
assert has_element?(page_3_pagination, "a", "2")
|
||||||
assert has_element?(page_3_pagination, "a", "4")
|
|
||||||
assert has_element?(page_3_pagination, "a", "5")
|
|
||||||
|
|
||||||
# All records in page 3 were not present in page 2
|
# All records in page 3 were not present in page 2
|
||||||
assert page_3_present -- page_2_absent == []
|
assert page_3_present -- page_2_absent == []
|
||||||
|
|||||||
Reference in New Issue
Block a user