fix: preserve pagination candidate type narrowing
This commit is contained in:
@@ -476,9 +476,9 @@ class WorkflowScheduleApi:
|
||||
raise ValueError("limit must be between 1 and 100")
|
||||
first_page = cursor in (None, "0")
|
||||
candidate = store.get_candidate(schedule_id)
|
||||
include_pending = candidate is not None and first_page
|
||||
pending_candidate = candidate if first_page else None
|
||||
stored_cursor = None if cursor == _PENDING_PAGE_CURSOR else cursor
|
||||
stored_limit = limit - 1 if include_pending else limit
|
||||
stored_limit = limit - 1 if pending_candidate is not None else limit
|
||||
if stored_limit:
|
||||
page = store.list_occurrences(
|
||||
schedule_id,
|
||||
@@ -501,16 +501,16 @@ class WorkflowScheduleApi:
|
||||
"next_cursor": (_PENDING_PAGE_CURSOR if stored_page["total"] else None),
|
||||
"limit": limit,
|
||||
}
|
||||
if include_pending:
|
||||
if pending_candidate is not None:
|
||||
now = datetime.now(UTC)
|
||||
intended = candidate.intended_at
|
||||
intended = pending_candidate.intended_at
|
||||
pending = OccurrenceRecord(
|
||||
schedule_id=schedule_id,
|
||||
occurrence_id=occurrence_id(schedule_id, intended),
|
||||
kind="pending",
|
||||
resolved_at=intended,
|
||||
run_id=None,
|
||||
revision=candidate.revision,
|
||||
revision=pending_candidate.revision,
|
||||
reason="",
|
||||
admitted_at=None,
|
||||
started_at=None,
|
||||
|
||||
Reference in New Issue
Block a user