feat: 采集任务可以立刻运行一次
This commit is contained in:
+11
-1
@@ -21,7 +21,7 @@ from app.nqi.adhoc import TIME_MODES, catalog_tree, categories, table_fields, ta
|
||||
from app.nqi.client import NqiAuthError, NqiClient, NqiError
|
||||
from app.nqi.flows import drop, purge, remember, take
|
||||
from app.security import hash_password, issue_token, verify_password
|
||||
from app.tasks.runner import check_concurrency, check_refresh, enqueue_export
|
||||
from app.tasks.runner import check_concurrency, check_refresh, enqueue_collection, enqueue_export
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
# 在响应发出前提交,客户端紧接着发出的请求才能读到刚写入的内容。
|
||||
@@ -623,6 +623,16 @@ def update_source(source_id: int, body: dict, actor: Actor = Depends(current_act
|
||||
return {"source": _public_source(source)}
|
||||
|
||||
|
||||
@router.post("/admin/sources/{source_id}/run")
|
||||
def run_source(source_id: int, actor: Actor = Depends(current_actor), session: Session = db_session) -> dict:
|
||||
require_admin(actor)
|
||||
source = session.get(CollectionSource, source_id)
|
||||
if source is None:
|
||||
raise _bad("采集不存在", 404)
|
||||
enqueue_collection(source.id, force=True)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.delete("/admin/sources/{source_id}")
|
||||
def delete_source(source_id: int, actor: Actor = Depends(current_actor), session: Session = db_session) -> dict:
|
||||
require_admin(actor)
|
||||
|
||||
Reference in New Issue
Block a user