@@ -568,9 +568,27 @@ def filter(self,
568568 if status == WorkflowExecution .STATUS_OPEN :
569569 oldest_date = kwargs .pop ('oldest_date' , 30 )
570570 else :
571- oldest_date = kwargs .pop ('start_oldest_date' , 30 )
571+ # The SWF docs on ListClosedWorkflowExecutions state that:
572+ #
573+ # "startTimeFilter and closeTimeFilter are mutually exclusive"
574+ #
575+ # so we must figure out if we have to add a default value for
576+ # start_oldest_date or not.
577+ if "close_latest_date" in kwargs or "close_oldest_date" in kwargs :
578+ default_oldest_date = None
579+ else :
580+ default_oldest_date = 30
581+ oldest_date = kwargs .pop ('start_oldest_date' , default_oldest_date )
582+
583+ # Compute a timestamp from the delta in days we got from params
584+ # If oldest_date is blank at this point, it's because we didn't want
585+ # it, so let's leave it blank and assume the user provided an other
586+ # time filter.
587+ if oldest_date :
588+ start_oldest_date = int (datetime_timestamp (past_day (oldest_date )))
589+ else :
590+ start_oldest_date = None
572591
573- start_oldest_date = datetime_timestamp (past_day (oldest_date ))
574592 return [self .to_WorkflowExecution (self .domain , wfe ) for wfe in
575593 self ._list_items (
576594 * args ,
@@ -579,7 +597,7 @@ def filter(self,
579597 workflow_id = workflow_id ,
580598 workflow_name = workflow_type_name ,
581599 workflow_version = workflow_type_version ,
582- start_oldest_date = int ( start_oldest_date ) ,
600+ start_oldest_date = start_oldest_date ,
583601 tag = tag ,
584602 ** kwargs
585603 )]
0 commit comments