talnagar commented on a change in pull request #21851:
URL: https://github.com/apache/airflow/pull/21851#discussion_r820232142



##########
File path: airflow/www/views.py
##########
@@ -1838,10 +1839,15 @@ def trigger(self, session=None):
                 form=form,
                 
is_dag_run_conf_overrides_params=is_dag_run_conf_overrides_params,
             )
-
-        dr = DagRun.find(dag_id=dag_id, execution_date=execution_date, 
run_type=DagRunType.MANUAL)
+        # if run_id is not None, filter dag runs based on run id and ignore 
execution date
+        dr = DagRun.find(
+            dag_id=dag_id,
+            run_type=DagRunType.MANUAL,
+            run_id=run_id,
+            execution_date=execution_date if run_id is None else None,

Review comment:
        DagRun.find() uses sqlalchemy if I understand it correctly:
   
https://github.com/apache/airflow/blob/2157787c77b0afa1eda7099849c18ace12908b98/airflow/models/dagrun.py#L305
   I can change it to something like this but it may be a little too verbose: 
   ```
    elif run_id is not None or execution_date is not None:
               qry = qry.filter((cls.run_id == run_id) | (cls.execution_date == 
execution_date))
           elif execution_date is not None and run_id is None:
               qry = qry.filter(cls.execution_date == execution_date)
           elif run_id is not None and execution_date is None:
               qry = qry.filter(cls.run_id == run_id)
   ```




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