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

Bulk Search and List Creator #9279

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

Conversation

benbdeitch
Copy link
Contributor

Closes #7653

With this PR, the long-requested Bulk Search feature is finally functional. It enables users to extract books and titles from sections of text, and search the Open LIbrary database for each pair, at the click of a button. ChatGPT-based extraction is functional, but requires the user to supply their own key for that purpose.

Technical

The majority of the changes involve the addition of a new Vue component. Rather than conveying information between individual components by event watchers, information is instead conveyed through a state defined in /openlibrary/components/BulkSearch/utils/classes.js.

Currently, the 'create a new list' function is not supported, but I intend to resolve that within the next few days.

Unfortunately, there were some limitations with how the table displays. Horizontal scrolling will likely be needed to navigate it, in cases where there are a large amount of works retrieved by a given search. This will likely be addressed in a future pull request.

Testing

Simply use the component, which is located at localhost:8080/bulk/search.

Screenshot

Stakeholders

@cdrini

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

Nice great work @benbdeitch ! Did a first pass 👍

Main notes:

  • I think you forgot to add the BulkSearch.vue file! 😁
  • Can you format the vue files? I'm not sure why it's not causing eslint troubles 🤔 But it's a little hard to read. I'd recommend installing the Vue offical VS code extension ( https://marketplace.visualstudio.com/items?itemName=Vue.volar ) and then for each file, run auto form shift-alt-f

return `https://covers.openlibrary.org/b/id/${this.doc.cover_i}-M.jpg`
},
workUrl() {
return `https://openlibrary.org/books/${this.doc.key.split('/')[2]}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be /works ?

Suggested change
return `https://openlibrary.org/books/${this.doc.key.split('/')[2]}`
return `/works/${this.doc.key.split('/')[2]}`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Books and works are interchangeable, so far as I recall. I think you're right though, this could probably be https://openlibrary.org/${this.doc.key}, from what I'm looking at.




<template>
Copy link
Collaborator

Choose a reason for hiding this comment

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

The template file should be at the top. We tend to do template, script, then css

Comment on lines 122 to 125
<details open>

<summary>Input</summary>
<div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This indenting needs to be cleaned up; auto-format all these files. I'm surprised we don't have a linter for these already configured!


<script>

import sampleBar from './SampleBar.vue'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We make components in UpperCamelCase.

Suggested change
import sampleBar from './SampleBar.vue'
import SampleBar from './SampleBar.vue'

<button @click="extractBooks">Extract Books</button>
<button @click="matchBooks">Match Books</button>
</div>
<div class="ErrorBox" v-if="this.bulkSearchState.errorMessage">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Our class names are generally kebab-case, but it seems like this class is unused, so can drop it.

Suggested change
<div class="ErrorBox" v-if="this.bulkSearchState.errorMessage">
<div v-if="this.bulkSearchState.errorMessage">

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's name this MatchRow ; Table is a little vague.


td,th { border: 1px solid; padding: 4px; }
.bookCards {
font-family: Roboto, sans-serif;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't need to set the font-family here, it should be inherited.

Suggested change
font-family: Roboto, sans-serif;

constructor(){
/** @type {string} */
this.inputText= '';
/** @type {ExtractedBooks[]} */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** @type {ExtractedBooks[]} */
/** @type {ExtractedBook[]} */

openlibrary/templates/bulk_search/demo.html Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can just be in bulk_search.html ; it's not a demo for long! ;)

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.

Bulk Search & List Creator
2 participants