Skip to content

Commit

Permalink
Run Trigger Page: Configurable number of recent configs (apache#36878)
Browse files Browse the repository at this point in the history
* Run Trigger Page: Configurable number of recent configs
* no abbreviations in configuration names
  • Loading branch information
AchimGaedkeLynker authored and flacode committed Jan 22, 2024
1 parent 83ef8a3 commit 11bf6b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,13 @@ webserver:
type: boolean
example: ~
default: "False"
num_recent_configurations_for_trigger:
description: |
Number of recent DAG run configurations in the selector on the trigger web form.
version_added: 2.9.0
type: integer
example: "10"
default: "5"
allow_raw_html_descriptions:
description: |
A DAG author is able to provide any raw HTML into ``doc_md`` or params description in
Expand Down
3 changes: 2 additions & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION):
flash(f"Cannot create dagruns because the dag {dag_id} has import errors", "error")
return redirect(origin)

num_recent_confs = conf.getint("webserver", "num_recent_configurations_for_trigger")
recent_runs = session.execute(
select(DagRun.conf, func.max(DagRun.run_id).label("run_id"), func.max(DagRun.execution_date))
.where(
Expand All @@ -2038,7 +2039,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION):
)
.group_by(DagRun.conf)
.order_by(func.max(DagRun.execution_date).desc())
.limit(5)
.limit(num_recent_confs)
)
recent_confs = {
run_id: json.dumps(run_conf)
Expand Down

0 comments on commit 11bf6b9

Please sign in to comment.