Skip to content

Conversation

@BearSunny
Copy link
Contributor

Phase 1 of #10760

Technical:

This PR introduces the foundational logic for our global Book Preferences filter, which will live on the top IA bar. While the full feature is not yet implemented, the code in this phase is intended to do the following:

  1. Retrieve user preferences from three sources: user account settings, session, and cookie.
  2. Validate and normalize those inputs for consistent filtering.
  3. Apply a layered filtering strategy: Base Config < Carousel-specific filter < User Preferences. This means user preferences will take precedence over both the base configuration and carousel-specific filter.

This logic allows users to set global preferences that automatically apply across all carousels, while still preserving each carousel's specific contents.

Testing:

This PR sets up the structure for the preference engine, but does not yet include unit tests. To proceed further, I would appreciate clarification on the following areas:

  1. What are the actual Solr schema field names and default carousel configs?
  2. What is the exact structure of our request object, and should we proceed under the assumption that user authentication is required?
  3. Where and how should we store user preferences (e.g., in a database, in session, etc.)?
  4. Which configuration file or source defines each carousel?
  5. I haven't seen the implementation for Add Dropdown Menu to Facet Carousels #10512 yet, so my carousel-specific filter overrides should only be a placeholder for now.

Looking forward to your inputs on these aspects and would be happy to build on this feature in the subsequent phases!

Stakeholders:

@mekarpeles
@cdrini

@BearSunny BearSunny marked this pull request as draft July 15, 2025 13:31
@BearSunny BearSunny marked this pull request as ready for review July 15, 2025 13:32
@BearSunny BearSunny marked this pull request as draft July 15, 2025 13:32
cdrini and others added 28 commits August 25, 2025 21:13
…internetarchive#11146)

* Add ISFDB identifiers for authors, works, and fix HTTPS for editions
…follow-button-overflow

Titles under a single line
…t-bugs

Fix bugs in preference migration script
…pdate-solr

Update solr to latest version, 9.9.0
…rnetarchive#11150)

* allow author records with just 'death_date' to count as "dated"
fixes internetarchive#10736
* refactor a has_dates() method to simplify logic
* explicitly test death_date only matching
for internetarchive#10736
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.9 → v0.12.10](astral-sh/ruff-pre-commit@v0.12.9...v0.12.10)
- [github.com/pre-commit/mirrors-eslint: v9.33.0 → v9.34.0](pre-commit/mirrors-eslint@v9.33.0...v9.34.0)
…r/remove-ol-redirects

remove old redirects
…idata-headers

set headers for wikidata get request
…btn-aesthetic

Remove border from ghost button styles
…list-card-corner

Fixed list corner radius
…mit-ci-update-config

[pre-commit.ci] pre-commit autoupdate
…te (internetarchive#11201)

* Partially address internetarchive#11200, remove unused no_index compute

---------

Co-authored-by: jimchamp <28732543+jimchamp@users.noreply.github.com>
…m-border

Remove border from dropdown menu in language.less
* standard library imports no longer nested

* remove legacy python 2 code
Scott noticed that the fields `title_sort` and `name` were appearing
frequently in Solr's fieldCache and consuming a lot of space (~1.8G for
`title`). He noted that the documentation recommends for things like
sorting/faceting, docValues are recommended -- which solr.TextField
doesn't support. But _does_ support them is the aptly names
solr.SortableTextField!

So we switched to that for our `title_sort` field, and for the author
`name` field we switched to instead sort by `name_str` which should
behave the same.

Co-authored-by: Scott Barnes <scottreidbarnes@gmail.com>
* use SubjectType typehint literals

* typehint literals as needed

* observations type literal

* add literal to schema.py

* fix circular import
Scott noticed that the fields `title_sort` and `name` were appearing
frequently in Solr's fieldCache and consuming a lot of space (~1.8G for
`title`). He noted that the documentation recommends for things like
sorting/faceting, docValues are recommended -- which solr.TextField
doesn't support. But _does_ support them is the aptly names
solr.SortableTextField!

So we switched to that for our `title_sort` field, and for the author
`name` field we switched to instead sort by `name_str` which should
behave the same.

Co-authored-by: Scott Barnes <scottreidbarnes@gmail.com>
@BearSunny
Copy link
Contributor Author

Hi @mekarpeles and @cdrini,

I’ve made updates to Carousel.js, preferences.js, preferences-handler.js, alert.html, and account.py to implement a global book filter with the following flow:

  1. The user submits a form via the UI.

  2. JavaScript sends the preferences to the server.

  3. The server processes the request, sets cookies for future use, and returns a success response.

  4. Upon receiving confirmation, JavaScript triggers an event instructing the carousels to reload content using the updated preferences.

  5. On subsequent page loads, preferences-handler.js hydrates localStorage with any existing filter cookies, ensuring the carousels (via Carousel.js) initialize with the correct preferences and apply them immediately on their first content fetch.

At this stage, the feature does not yet guarantee that preferences persist after a user performs a search. Oh and by the way, I'm a bit confused why there are so many changed files in this PR?

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.