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

Add endpoint to view status of batch import #9682

Merged
merged 6 commits into from
Aug 9, 2024

Conversation

cdrini
Copy link
Collaborator

@cdrini cdrini commented Aug 2, 2024

Closes #9681

Add endpoint to view status of batch import (/import/batch/<id>).

  • New Class and Endpoint:

    • Add BatchImportView class in openlibrary/plugins/openlibrary/code.py for the path /import/batch/(\d+) with a GET handler.
    • Implement the GET handler to retrieve batch import status from the database.
    • Support pagination (page and limit) and sorting (added_time, import_time, status) in the handler.
    • Perform a GROUP BY query by status to get the total number of rows for the batch.
  • Template for Batch Import View:

    • Create a new template file openlibrary/templates/batch_import_view.html to display the batch import status.
    • Include a table with columns for all fields in the import_item table.
    • Support pagination and sorting in the table.
    • Display the grouped status counts at the top.
  • Update Batch Import Template:

    • Update openlibrary/templates/batch_import.html to link to the new endpoint after creating a batch.

For more details, open the Copilot Workspace session.

cdrini and others added 2 commits August 2, 2024 16:59
Closes #9681

Add endpoint to view status of batch import (`/import/batch/<id>`).

* **New Class and Endpoint:**
  - Add `BatchImportView` class in `openlibrary/plugins/openlibrary/code.py` for the path `/import/batch/(\d+)` with a `GET` handler.
  - Implement the `GET` handler to retrieve batch import status from the database.
  - Support pagination (`page` and `limit`) and sorting (`added_time`, `import_time`, `status`) in the handler.
  - Perform a `GROUP BY` query by `status` to get the total number of rows for the batch.

* **Template for Batch Import View:**
  - Create a new template file `openlibrary/templates/batch_import_view.html` to display the batch import status.
  - Include a table with columns for all fields in the `import_item` table.
  - Support pagination and sorting in the table.
  - Display the grouped status counts at the top.

* **Update Batch Import Template:**
  - Update `openlibrary/templates/batch_import.html` to link to the new endpoint after creating a batch.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/internetarchive/openlibrary/issues/9681?shareId=XXXX-XXXX-XXXX-XXXX).
@cdrini cdrini marked this pull request as ready for review August 2, 2024 15:25
Copy link
Collaborator

@scottbarnes scottbarnes left a comment

Choose a reason for hiding this comment

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

I must say, this is quite slick. One small suggestion.

$for row in rows:
<tr>
<td>$datestr(row.added_time)</td>
<td>$datestr(row.import_time)</td>
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
<td>$datestr(row.import_time)</td>
$if row.import_time:
<td>$datestr(row.import_time)</td>
$else:
<td>not yet imported</td>

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not actually sure whether Templetor supports ternary operations, but something like this should avoid an error from datestr() when there is no row.import_time, which will be the case for pending and staged items.

@scottbarnes scottbarnes added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Aug 9, 2024
@github-actions github-actions bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Aug 9, 2024
@cdrini cdrini merged commit c25e145 into master Aug 9, 2024
4 checks passed
@cdrini cdrini deleted the cdrini/add-batch-import-status branch August 9, 2024 15:14
Souvik-Cyclic pushed a commit to Souvik-Cyclic/openlibrary that referenced this pull request Aug 17, 2024
SivanC pushed a commit to SivanC/openlibrary that referenced this pull request Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add endpoint to view status of batch import (/import/batch/<id>)
2 participants