Skip to content

Add Custom Sort Option to To-Read List (#71) - #322

Open
aspaplag wants to merge 2 commits into
bayang:mainfrom
aspaplag:custom-order-to-read-list
Open

Add Custom Sort Option to To-Read List (#71)#322
aspaplag wants to merge 2 commits into
bayang:mainfrom
aspaplag:custom-order-to-read-list

Conversation

@aspaplag

Copy link
Copy Markdown

This closes issue #71

Changes Made

  • added a new column in userbook table in liquibase to store the custom to-read order (int for each book place)
  • added the custom to-read order column in UserBookTable.kt table definition
  • added field of custom order in UserBookLightDto and UserBookUpdateDto in UserBookDto
  • added updateCustomToRead() method to save user's custom order to BookRepostiory.kt for each book
  • added method to BookService to save a set of int order places
  • added endpoint in BooksController that accepts a mapped set of ids and gives it to BookService
  • added a test for whether the custom order is saved and persists
  • added a custom sort toggle that loads the unpaginated to-read list and makes the cards draggable. There is a save button and the custom sort order can be viewed in the filters sidebar
  • added updateBookSortOrder in dataservice which sends the new order to the endpoint

(Hello, this was done as part of a software engineering course, and part of it contributing to an OSS project of our choice. I don't expect it to be accepted but i would appreciate feedback if you have time and you want to. Thanks!)

aspaplag added 2 commits May 24, 2026 13:26
added backend methods and changes

changed toread ui and added sortablejs

removed personal use comments

linting and test of method
@bayang

bayang commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Ok thank you for this contribution.
I will need some time to review it.

@bayang

bayang commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Hi,
I don't know if you are still interested in merging this, but here are a few remarks.

The code looks good, my biggest concern is that you are loading the entire DB in memory to perform the custom sort.
For the users that have a huge collection it could potentially lead to bad performance issues, lagging UI, memory exhaustion etc...
I don't know if you tried to think to an alternate way where the custom sorting would happen in chunks or pages ?

Also, do you have a mechanism to prevent collisions in sort order ? An user could modify the order in the UI while the order is also modified in DB using the API for example. What would happen with two books having the same order number ?

true, ownedAsBool.value, null,
pageAsNumber.value - 1, perPage.value, sortQuery.value)
true, ownedAsBool.value, null,
0, pageSize, sortParam)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure that the page number should be harcoded to 0 ? I think it should be 0 only when in custom sort mode. You need the same logic as above with pageSize and sortParam

// method to update custom to-read list order
@Transactional
fun updateCustomToRead(sortOrders: Map<UUID, Int>) {
sortOrders.forEach { (userBookId, order) ->

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are looping over a potential big number of changes in a Transactional block.
Is there a way to persist the changes in DB in one SQL/one ORM call instead ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants