fix(fulfillment): reconcile stale pending roles from newer observations
This commit is contained in:
@@ -25,10 +25,11 @@ from ...models import (
|
||||
)
|
||||
from ...permissions import ROLE_LABELS
|
||||
from ..douyu_binding import (
|
||||
BINDING_OBSERVATION_TASK_TYPES,
|
||||
BINDING_VIEW_CONFIRMED,
|
||||
BINDING_VIEW_FAILED,
|
||||
BINDING_VIEW_PENDING,
|
||||
resolve_douyu_binding,
|
||||
resolve_fulfillment_binding,
|
||||
)
|
||||
from ..file_service import build_file_url
|
||||
from . import classification
|
||||
@@ -364,9 +365,10 @@ def _task_out(
|
||||
)
|
||||
collab_order = resolved.collab_orders.get(int(task.id))
|
||||
bind_result = (bind_task.result or {}) if bind_task else {}
|
||||
binding = resolve_douyu_binding(
|
||||
binding = resolve_fulfillment_binding(
|
||||
bind_task,
|
||||
account=account,
|
||||
binding_status=task.binding_status,
|
||||
)
|
||||
effective_issue = _effective_binding_issue(task, bind_task, bind_result)
|
||||
effective_last_error = _effective_task_message(task, effective_issue)
|
||||
@@ -599,8 +601,15 @@ def _customer_binding_queue_state(
|
||||
return "failed", 0
|
||||
if bind_task is None:
|
||||
return "ready_to_start", 0
|
||||
binding = resolve_douyu_binding(
|
||||
if (
|
||||
bind_task.task_type in BINDING_OBSERVATION_TASK_TYPES
|
||||
and task.binding_status != "bound"
|
||||
):
|
||||
return "ready_to_start", 0
|
||||
binding = resolve_fulfillment_binding(
|
||||
bind_task,
|
||||
account=None,
|
||||
binding_status=task.binding_status,
|
||||
)
|
||||
if binding.status == BINDING_VIEW_CONFIRMED:
|
||||
return "confirmed", 0
|
||||
@@ -630,9 +639,10 @@ def customer_binding_out(db: Session, task_id: int) -> dict[str, Any]:
|
||||
)
|
||||
bind_result = (bind_task.result or {}) if bind_task else {}
|
||||
account = db.get(Account, int(task.account_id)) if task.account_id else None
|
||||
binding = resolve_douyu_binding(
|
||||
binding = resolve_fulfillment_binding(
|
||||
bind_task,
|
||||
account=account,
|
||||
binding_status=task.binding_status,
|
||||
)
|
||||
effective_issue = _effective_binding_issue(task, bind_task, bind_result)
|
||||
lease = (
|
||||
|
||||
Reference in New Issue
Block a user