(self, batch_id)
| 476 | path = r"/import/batch/(\d+)" |
| 477 | |
| 478 | def GET(self, batch_id): |
| 479 | i = web.input(page=1, limit=10, sort="added_time asc") |
| 480 | page = int(i.page) |
| 481 | limit = int(i.limit) |
| 482 | sort = i.sort |
| 483 | |
| 484 | valid_sort_fields = ["added_time", "import_time", "status"] |
| 485 | sort_field, sort_order = sort.split() |
| 486 | if sort_field not in valid_sort_fields or sort_order not in ["asc", "desc"]: |
| 487 | sort_field = "added_time" |
| 488 | sort_order = "asc" |
| 489 | |
| 490 | offset = (page - 1) * limit |
| 491 | |
| 492 | batch = db.select("import_batch", where="id=$batch_id", vars=locals())[0] |
| 493 | total_rows = db.query( |
| 494 | "SELECT COUNT(*) AS count FROM import_item WHERE batch_id=$batch_id", |
| 495 | vars=locals(), |
| 496 | )[0].count |
| 497 | |
| 498 | rows = db.select( |
| 499 | "import_item", |
| 500 | where="batch_id=$batch_id", |
| 501 | order=f"{sort_field} {sort_order}", |
| 502 | limit=limit, |
| 503 | offset=offset, |
| 504 | vars=locals(), |
| 505 | ) |
| 506 | |
| 507 | status_counts = db.query( |
| 508 | "SELECT status, COUNT(*) AS count FROM import_item WHERE batch_id=$batch_id GROUP BY status", |
| 509 | vars=locals(), |
| 510 | ) |
| 511 | |
| 512 | return render_template( |
| 513 | "batch_import_view.html", |
| 514 | batch=batch, |
| 515 | rows=rows, |
| 516 | total_rows=total_rows, |
| 517 | page=page, |
| 518 | limit=limit, |
| 519 | sort=sort, |
| 520 | status_counts=status_counts, |
| 521 | ) |
| 522 | |
| 523 | |
| 524 | class BatchImportApprove(delegate.page): |
nothing calls this directly
no test coverage detected