-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
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).
for more information, see https://pre-commit.ci
There was a problem hiding this 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<td>$datestr(row.import_time)</td> | |
$if row.import_time: | |
<td>$datestr(row.import_time)</td> | |
$else: | |
<td>not yet imported</td> |
There was a problem hiding this comment.
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.
for more information, see https://pre-commit.ci
Closes #9681
Add endpoint to view status of batch import (
/import/batch/<id>
).New Class and Endpoint:
BatchImportView
class inopenlibrary/plugins/openlibrary/code.py
for the path/import/batch/(\d+)
with aGET
handler.GET
handler to retrieve batch import status from the database.page
andlimit
) and sorting (added_time
,import_time
,status
) in the handler.GROUP BY
query bystatus
to get the total number of rows for the batch.Template for Batch Import View:
openlibrary/templates/batch_import_view.html
to display the batch import status.import_item
table.Update Batch Import Template:
openlibrary/templates/batch_import.html
to link to the new endpoint after creating a batch.For more details, open the Copilot Workspace session.