jedcunningham commented on code in PR #27839:
URL: https://github.com/apache/airflow/pull/27839#discussion_r1030598520
##########
airflow/www/views.py:
##########
@@ -851,6 +851,36 @@ def datasets(self):
state_color_mapping=state_color_mapping,
)
+ @expose("/next_run_datasets_summary", methods=["POST"])
+ @auth.has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG)])
+ @provide_session
+ def next_run_datasets_summary(self, session=None):
+ """Next run info for dataset triggered DAGs."""
+ allowed_dag_ids =
get_airflow_app().appbuilder.sm.get_accessible_dag_ids(g.user)
+
+ if not allowed_dag_ids:
+ return flask.json.jsonify({})
+
+ # Filter by post parameters
+ selected_dag_ids = {unquote(dag_id) for dag_id in
request.form.getlist("dag_ids") if dag_id}
+
+ if selected_dag_ids:
+ filter_dag_ids = selected_dag_ids.intersection(allowed_dag_ids)
+ else:
+ filter_dag_ids = allowed_dag_ids
+
+ dataset_triggered_dag_ids = (
+ session.query(DagModel.dag_id)
+ .filter(DagModel.dag_id.in_(filter_dag_ids))
+ .filter(DagModel.schedule_interval == "Dataset")
+ )
Review Comment:
```suggestion
dataset_triggered_dag_ids = [
dag.dag_id
for dag in
session.query(DagModel.dag_id)
.filter(DagModel.dag_id.in_(filter_dag_ids))
.filter(DagModel.schedule_interval == "Dataset")
]
```
Might need some formatting, but let's do this instead - that way we pass
list[str] to get_dataset_triggered_next_run_info like it expects.
##########
airflow/www/static/js/dags.js:
##########
@@ -271,6 +273,25 @@ function dagStatsHandler(selector, json) {
});
}
+function nextRunDatasetsSummaryHandler(json) {
+ [...document.getElementsByClassName('next-dataset-triggered')].forEach((el)
=> {
+ const dagId = $(el).attr('data-dag-id');
+ const previousSummary = $(el).attr('data-summary');
+ const nextDatasetsInfo = json[dagId];
+
+ // Only update dags that depend on multiple datasets
+ if (!nextDatasetsInfo.uri) {
+ const newSummary = `${nextDatasetsInfo.ready} of
${nextDatasetsInfo.total} datasets updated`;
+
+ // Only updated the element if the summary has changed
Review Comment:
```suggestion
// Only update the element if the summary has changed
```
--
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]