fix(nodes): fix off-by-one page count error

This commit is contained in:
psychedelicious 2023-04-04 16:38:37 +10:00
parent 406039426a
commit de0df4945d
2 changed files with 8 additions and 3 deletions

View File

@ -95,7 +95,10 @@ class DiskImageStorage(ImageStorageBase):
count = len(all_images)
page_of_images = all_images[page * per_page : (page + 1) * per_page]
page_count = int(count / per_page) + 1
page_count_trunc = int(count / per_page)
page_count_mod = count % per_page
page_count = page_count_trunc if page_count_mod == 0 else page_count_trunc + 1
return PaginatedResults[ImageField](
items=page_of_images,

View File

@ -106,10 +106,12 @@ class SqliteItemStorage(ItemStorageABC, Generic[T]):
finally:
self._lock.release()
pageCount = int(count / per_page) + 1
page_count_trunc = int(count / per_page)
page_count_mod = count % per_page
page_count = page_count_trunc if page_count_mod == 0 else page_count_trunc + 1
return PaginatedResults[T](
items=items, page=page, pages=pageCount, per_page=per_page, total=count
items=items, page=page, pages=page_count, per_page=per_page, total=count
)
def search(