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

Check whether ISBN already exists if manually adding a book #7113

Open
Tracked by #7684
onnotasler opened this issue Oct 31, 2022 · 15 comments · May be fixed by #8912
Open
Tracked by #7684

Check whether ISBN already exists if manually adding a book #7113

onnotasler opened this issue Oct 31, 2022 · 15 comments · May be fixed by #8912
Assignees
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Module: Import Issues related to the configuration or use of importbot and other bulk import systems. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]

Comments

@onnotasler
Copy link
Collaborator

When searching for a book or author, it is sometimes not found. Searching for an ISBN might cause a delayed import that will not be found immediately.

In that case, I feel inclined to manually import a book. Despite entering the ISBN, there is no check whether this ISBN already exists. This might cause duplicates.

Describe the problem that you'd like solved

If I enter an ISBN in the add book page, there should be a background check on whether this ISBN already exists to prevent duplicates.

If a work already exists, I should get a notification and be asked whether those books might need to be merged or an error needs to be reported (for example, because an edition is connected to the wrong work).

Proposal & Constraints

The author field has a similar functionality, which looks for author with similar spellings.

Additional context

#3473
#7055

Stakeholders

@mekarpeles @cdrini

@onnotasler onnotasler added Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed] labels Oct 31, 2022
@MingdaMa
Copy link

MingdaMa commented Nov 9, 2022

Hi, I will start working on this issue

@mekarpeles mekarpeles added Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] and removed Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] labels Nov 14, 2022
@mekarpeles
Copy link
Member

Maybe when the patron clicks on the isbn field, if they have js enabled, then we will check /isbn/{isbn} to see if the item exists and if so, show a popup with the existing matching books and say "go to book" or "keep adding" (please actually come up with better text than those examples)

@mekarpeles
Copy link
Member

@MingdaMa please let us know if you need help with this issue:

  1. look in plugins/openlibrary/js/ for the right place to add code for the import /addbooks page
  2. after an isbn is pasted in the field (debounced) then lookup the isbn with a fetch to openlibrary.org/isbn/{isbn}
  3. If the API returns data back, then inject a html snippet into the page which shows the matching book with a message "an existing book was found with ISBN {isbn}: openlibrary.org/isbn/{isbn}"

@MingdaMa
Copy link

@MingdaMa please let us know if you need help with this issue:

  1. look in plugins/openlibrary/js/ for the right place to add code for the import /addbooks page
  2. after an isbn is pasted in the field (debounced) then lookup the isbn with a fetch to openlibrary.org/isbn/{isbn}
  3. If the API returns data back, then inject a html snippet into the page which shows the matching book with a message "an existing book was found with ISBN {isbn}: openlibrary.org/isbn/{isbn}"

Thanks for the instruction, it's my first time working on this project so I'm a bit slow. I'll keep working on it!

@scottbarnes scottbarnes mentioned this issue Mar 18, 2023
35 tasks
@scottbarnes
Copy link
Collaborator

@MingdaMa, are you still interested in this? If you are, then great! Please ask any and all questions you have. But if not, I'd like to make it a bit easier to find for those who might wish to work on this.

@MingdaMa
Copy link

@MingdaMa, are you still interested in this? If you are, then great! Please ask any and all questions you have. But if not, I'd like to make it a bit easier to find for those who might wish to work on this.

Thanks for checking in! I am still interested in this, the problem I have right now is when I try to call the api, I will get a CORS error and I'm still trying to figure this out.

@jimchamp jimchamp added the Module: Import Issues related to the configuration or use of importbot and other bulk import systems. [managed] label Mar 28, 2023
Copy link

Assignees removed automatically after 14 days.

@mekarpeles mekarpeles added Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Lead: @mheiman Good First Issue Easy issue. Good for newcomers. [managed] and removed Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Lead: @mheiman labels Jan 26, 2024
@Dwayne-Lacey
Copy link
Contributor

Hey @jimchamp can this be assigned to me?

@jimchamp
Copy link
Collaborator

jimchamp commented Mar 7, 2024

@Dwayne-Lacey, you've been assigned. Let me know if you have any questions or run into any issues.

@Dwayne-Lacey
Copy link
Contributor

Dwayne-Lacey commented Mar 9, 2024

Hey @jimchamp so I've been working on adding the fetch request and I was having some issues getting any sort of response when using openlibrary.org/isbn/0553381687 to test. I was wondering if there might've been something I was missing or if the endpoint should be something else.

This was the snippet of my test code, just trying to look at what the response itself would look like, but I kept receiving a timeout due to typeError

const fetchPromise = fetch('https://openlibrary.org/isbn/0553381687');
        fetchPromise.then(resp => {
            console.log(resp);
        });

@jimchamp
Copy link
Collaborator

Sorry for the delay! The /isbn/{isbn_number} endpoints ultimately redirect to a book page. I think that the handler for those endpoints also attempts to fetch book data from third-parties when an ISBN is missing (citation needed... this functionality may have been disabled recently).

Try using the .json endpoint for this case: /isbn/{isbn_number}.json.

If that doesn't help, you may want to open your browser's devtools and check request and response in the "Network" tab.

@scottbarnes
Copy link
Collaborator

It's poorly documented and that is something I want to improve, but this comment has a bit of an explanation of the /isbn endpoint, which has been re-enabled as of the last deploy: #8690 (comment).

The short of it is that to immediately attempt an import by ISBN and return JSON, the request would be to, e.g., https://openlibrary.org/isbn/0553381687.json?high_priority=true

@jimchamp
Copy link
Collaborator

@scottbarnes, do these /isbn endpoints always attempt to import a book? If so, is this going to lead to redundant records? Is the record that was submitted by the patron going to get clobbered by the import?

@jimchamp
Copy link
Collaborator

jimchamp commented Mar 20, 2024

@mekarpeles, if the isbn matches an existing book, do we prevent the add book form from being submitted? Today, whenever a add book from with an invalid isbn is submitted, the submitter is prompted to confirm that they actually want to add the invalid ID. Should we give the same option for these cases?

@scottbarnes
Copy link
Collaborator

scottbarnes commented Mar 20, 2024

/isbn should not try to import by default, even if high_priority=True is passed. I sadly still only have documentation in that comment, but I am getting closer to this endpoint.

That said, when one queries /isbn:

  1. First the Open Library database is searched for that ISBN, and if a match is found, that matched edition is returned;
  2. If no existing match is found, the import_item table will be checked for staged entries that match, an imported will be attempted based on that match, and a new edition if any will be returned;
  3. Finally, in the default case the ISBN will either be staged for import via the affiliate-server (and the browser will get a 'not found' message). If high_priority=True an import will be attempted for the ISBN if matching data is found via the affiliate-server, and the new edition, if any, is returned.

In terms of what this means for clobbering, I guess that depends on the mechanics of the change. I do not think it would clobber anything from the patron, though. From the current PR my understanding is that if a match is found, that is reported back to the patron (and we need to do decide what to do), and if a match isn't found, then if any metadata was found in step (3), it would be staged for import via the affiliate-server (so that the same metadata doesn't need to be looked up again via the affiliate-server).

@jimchamp jimchamp removed the Good First Issue Easy issue. Good for newcomers. [managed] label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Module: Import Issues related to the configuration or use of importbot and other bulk import systems. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants