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

import api: use edition ID from IA metadata if it exists #8331

Conversation

scottbarnes
Copy link
Collaborator

Related: #8290 #8289

Fix

Technical

Currently ia_import() in the import API does not use Open Library edition IDs from Internet Archive metadata because it is using the wrong field -- metadata['openlibrary'] instead of metadata[openlibrary_edition].

This PR fixes that, and ensures we won't make a new edition when trying to import an IA record. Additionally, it avoids at least two further database calls that would have been made in an attempt to find a match.

Testing

Try to import an IA record and see that 'step 2' now works as intended and gets the existing Open Library edition ID from the Internet Archive metadata, rather than relying on finding a match by searching the Open Library database.

❯ http POST http://localhost:8080/api/import/ia identifier==007exoticlocatio0000arno Cookie:$OL_COOKIE
HTTP/1.1 200 OK
[...]

{
    "edition": {
        "key": "/books/OL8582004M",
        "status": "modified"
    },
    "success": true,
    "work": {
        "key": "/works/OL8839644W",
        "status": "matched"
    }
}

@cdrini

@cdrini cdrini added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Sep 25, 2023
Copy link
Member

@mekarpeles mekarpeles left a comment

Choose a reason for hiding this comment

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

➕ 1 -- openlibrary is a deprecated key name on archive.org, openlibrary_[edition|work] are preferred

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm!

@cdrini cdrini merged commit 24cad47 into internetarchive:master Sep 28, 2023
2 checks passed
@scottbarnes scottbarnes deleted the fix/ia_import_uses_wrong_field_for_openlibrary_edition branch October 17, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants