Implement reverseOrder option for GetWorkflowExecutionHistory and PollForDecisionTask
This commit is contained in:
parent
c16da9da2d
commit
aa4adbb76e
6 changed files with 40 additions and 15 deletions
|
|
@ -16,10 +16,11 @@ class DecisionTask(object):
|
|||
# but that shouldn't be a problem for tests
|
||||
self.scheduled_at = datetime.now()
|
||||
|
||||
def to_full_dict(self):
|
||||
def to_full_dict(self, reverse_order=False):
|
||||
events = self.workflow_execution.events(reverse_order=reverse_order)
|
||||
hsh = {
|
||||
"events": [
|
||||
evt.to_dict() for evt in self.workflow_execution.events
|
||||
evt.to_dict() for evt in events
|
||||
],
|
||||
"taskToken": self.task_token,
|
||||
"previousStartedEventId": self.previous_started_event_id,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class WorkflowExecution(object):
|
|||
"openChildWorkflowExecutions": 0,
|
||||
}
|
||||
# events
|
||||
self.events = []
|
||||
self._events = []
|
||||
# tasks
|
||||
self.decision_tasks = []
|
||||
self.activity_tasks = []
|
||||
|
|
@ -97,13 +97,19 @@ class WorkflowExecution(object):
|
|||
hsh["openCounts"] = self.open_counts
|
||||
return hsh
|
||||
|
||||
def events(self, reverse_order=False):
|
||||
if reverse_order:
|
||||
return reversed(self._events)
|
||||
else:
|
||||
return self._events
|
||||
|
||||
def next_event_id(self):
|
||||
event_ids = [evt.event_id for evt in self.events]
|
||||
event_ids = [evt.event_id for evt in self._events]
|
||||
return max(event_ids or [0])
|
||||
|
||||
def _add_event(self, *args, **kwargs):
|
||||
evt = HistoryEvent(self.next_event_id(), *args, **kwargs)
|
||||
self.events.append(evt)
|
||||
self._events.append(evt)
|
||||
return evt
|
||||
|
||||
def start(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue