ephraimbuddy commented on a change in pull request #17945:
URL: https://github.com/apache/airflow/pull/17945#discussion_r700921368



##########
File path: airflow/models/dagrun.py
##########
@@ -224,6 +224,26 @@ def next_dagruns_to_examine(
             query.limit(max_number), of=cls, session=session, 
**skip_locked(session=session)
         )
 
+    @classmethod
+    def get_next_queued_dagruns_for_dag(cls, dag_id: str, session: Session, 
max_number: Optional[int] = None):
+        """Get queued dagruns for a particular dag to examine"""
+        if max_number is None:
+            max_number = cls.DEFAULT_DAGRUNS_TO_EXAMINE
+        query = (
+            session.query(cls)
+            .filter(cls.dag_id == dag_id, cls.state == State.QUEUED)
+            .order_by(
+                nulls_first(cls.last_scheduling_decision, session=session),
+                cls.execution_date,
+            )
+        )
+        if not settings.ALLOW_FUTURE_EXEC_DATES:
+            query = query.filter(DagRun.execution_date <= func.now())
+
+        return with_row_locks(
+            query.limit(max_number), of=cls, session=session, 
**skip_locked(session=session)
+        )

Review comment:
       I feel it should be here so we can test it separately? The method 
calling it from scheduler is already big. Fine with me to move it to where it's 
used but will like to hear what you think again




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to