Skip to content

Adding primitive support for likes #12768#12932

Open
shreya8040 wants to merge 2 commits into
internetarchive:masterfrom
shreya8040:issue-12768-likes
Open

Adding primitive support for likes #12768#12932
shreya8040 wants to merge 2 commits into
internetarchive:masterfrom
shreya8040:issue-12768-likes

Conversation

@shreya8040

Copy link
Copy Markdown
Contributor

Closes #12768

Added a likes table to the Open Library database, a openlibrary/core/likes.py model, and a small set of backend API endpoints.

Technical

  • Added likes table DDL to scripts/db_setup.py
  • Added openlibrary/core/likes.py with Likes class (like, unlike, dislike, get_count, get_for_patron, patron_liked)
  • Registered API endpoints in openlibrary/plugins/upstream/code.py:
    • POST /api/like — like or dislike a record (auth required)
    • DELETE /api/like — remove a like (auth required)
    • GET /api/likes — get like/dislike count + patron_liked flag
    • GET /api/patron/likes — get all likes by a patron (paginated)
  • Auth enforcement: unauthenticated requests return 401
  • Added unit tests covering: like, unlike, double-like idempotency, value constraint, unauthenticated rejection
  • Added # TODO comment in likes.py documenting the redirect/merge gap and pointing to resolve_redirects_bulk

Testing

No UI changes — backend only. Run unit tests with:
docker compose run --rm home pytest openlibrary/plugins/openlibrary/tests/test_likes.py

Note: test suite currently blocked by upstream NameError: name 'Locale' is not defined in conftest.py (unrelated to this PR).

Screenshot

Stakeholders

@mekarpeles

@github-actions github-actions Bot added the Priority: 2 Important, as time permits. [managed] label Jun 15, 2026
@mekarpeles mekarpeles changed the title Issue #12768 Adding "Like" Primitive Support #12768 Jun 17, 2026
@shreya8040 shreya8040 changed the title Adding "Like" Primitive Support #12768 Adding primitive support for likes #12768 Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 2 Important, as time permits. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add generic likes table + backend APIs so patrons can like/dislike any OL record

3 participants