Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language imports consistently on re-imports of books #10213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qotkdrn
Copy link

@qotkdrn qotkdrn commented Dec 28, 2024

Closes #10141 Internet Archive imports often missing language

Fix

Fixes language import issue by ensuring that language is correctly added to existing editions during import

Technical

Previously, the issue was that when importing an edition, the language field was not being correctly added to existing editions if it was missing, even if the import record contained a language.

To address this I added a helper function format_languages() to openlibrary/openlibrary/catalog/add_book/init.py,
to format the languages field, called by update_edition_with_rec_data() and build_query() in openlibrary/openlibrary/catalog/add_book/load_book.py, along with changes to both functions.

Testing

Tested this issue locally and reproduced the bug by running the following commands (generate command and import book).

$ curl -c cookies.txt -X POST "http://localhost:8080/account/login" -d "username=[email protected]&password=admin123"
$ curl -L -v -X POST "http://localhost:8080/api/import/ia"
-b ./cookies.txt
-d "identifier=isbn_9781849353946&require_marc=false&force_import=true"

The book should now appear under http://localhost:8080/books/OL5M/

Screenshot 2024-12-27 at 4 18 29 PM

However, if we delete the language field and reimport the book, the language fields remains missing.
http://localhost:8080/books/OL5M.yml?m=edit

Screenshot 2024-12-27 at 4 22 12 PM Screenshot 2024-12-27 at 4 23 39 PM

After the changes, languages should now be correctly added.

Stakeholders

@scottbarnes

@github-actions github-actions bot added the Priority: 2 Important, as time permits. [managed] label Dec 28, 2024
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.

Internet Archive imports often missing language
2 participants