uranusjr commented on a change in pull request #17945:
URL: https://github.com/apache/airflow/pull/17945#discussion_r700930108
##########
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:
How about making this a seprate function in `scheduler_job.py`? That
would make this testable; my main concern is only about putting this on
`DagRun`.
--
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]