Skip to content

Allow bookmarks to be sorted by most recent - #5573

Open
rladdusaw wants to merge 16 commits into
mainfrom
4948-recently-bookmarked
Open

Allow bookmarks to be sorted by most recent#5573
rladdusaw wants to merge 16 commits into
mainfrom
4948-recently-bookmarked

Conversation

@rladdusaw

Copy link
Copy Markdown
Contributor

Resolves #4948

@rladdusaw
rladdusaw force-pushed the 4948-recently-bookmarked branch 2 times, most recently from c622d03 to 3ef400b Compare February 5, 2026 22:08
@rladdusaw
rladdusaw marked this pull request as ready for review February 6, 2026 14:17
@coveralls

coveralls commented Feb 6, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 95.146% (-0.003%) from 95.149%
when pulling 770d6c4 on 4948-recently-bookmarked
into a8ad661 on main.

@rladdusaw
rladdusaw force-pushed the 4948-recently-bookmarked branch from 0586d18 to 770d6c4 Compare February 12, 2026 15:19

@sandbergja sandbergja left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @rladdusaw 🐈‍⬛ . A few questions.

Comment on lines +8 to +17
def sort_by_most_recently_bookmarked(documents, user)
update_blank_sort_param
if params[:sort] == 'score desc' && bookmarks? && user
user.bookmarks.order(updated_at: :desc)
.collect { |bookmark| bookmark.document_id.to_s }
.filter_map { |id| documents.index_by(&:id)[id] }
else
documents
end
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this logic be moved to the Bookmarks Controller? The helpers have global scope, so it would be more cohesive to keep the logic there.

this.update_sort_text();
}

update_sort_text() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure we couldn't handle this on the ruby side? It seems odd for us to render the wrong options in Ruby only to correct them in JS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The text of the dropdown says sort by recently bookmarked on the catalog search page even though it's not an option in the dropdown for that page and the relevance sort is the one being used on the page. I spent a lot of time trying to get it to display properly, but nothing we tried worked. It's not an ideal solution, but the Blacklight config seems resistant to configuring a dynamic first sort option and this was the only way we could get it working.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One question: did you consider modifying the choices in a custom Blacklight::Response::SortComponent or similar?

Comment thread spec/requests/request_spec.rb Outdated
it 'excludes scsb items when pul location filter is applied' do
get '/catalog.json?per_page=100&f_inclusive%5Badvanced_location_s%5D%5B%5D=pul'
expect(response.body).to include('"99118884033506421"')
expect(response.body).to include('"9918150543506421"')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did this record change?

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.

[Bookmarks] Adding "Recently bookmarked" as the default sort on the Bookmarks Page

4 participants