You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/26 17:11:15 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #16086: Refactor `dag.clear` method

kaxil commented on a change in pull request #16086:
URL: https://github.com/apache/airflow/pull/16086#discussion_r639942923



##########
File path: airflow/models/dag.py
##########
@@ -1025,11 +1025,70 @@ def get_task_instances(self, start_date=None, end_date=None, state=None, session
             start_date = (timezone.utcnow() - timedelta(30)).date()
             start_date = timezone.make_aware(datetime.combine(start_date, datetime.min.time()))
 
-        tis = session.query(TaskInstance).filter(
-            TaskInstance.dag_id == self.dag_id,
-            TaskInstance.execution_date >= start_date,
-            TaskInstance.task_id.in_([t.task_id for t in self.tasks]),
+        return (
+            self._get_task_instances(
+                task_ids=None,
+                start_date=start_date,
+                end_date=end_date,
+                state=state,
+                include_subdags=False,
+                include_parentdag=False,
+                include_dependent_dags=False,
+                as_pk_tuple=False,
+                session=session,
+            )
+            .order_by(TaskInstance.execution_date)
+            .all()
         )
+
+    def _get_task_instances(
+        self,
+        *,
+        task_ids,

Review comment:
       We can make `task_ids` optional too here




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org