dstandish commented on code in PR #26942:
URL: https://github.com/apache/airflow/pull/26942#discussion_r992756303


##########
airflow/www/views.py:
##########
@@ -3574,23 +3574,28 @@ def datasets_summary(self):
 
             count_query = session.query(func.count(DatasetModel.id))
 
+            has_event_filters = bool(updated_before or updated_after)
+
             query = (
                 session.query(
                     DatasetModel.id,
                     DatasetModel.uri,
                     
func.max(DatasetEvent.timestamp).label("last_dataset_update"),
-                    
func.count(distinct(DatasetEvent.id)).label("total_updates"),
+                    
func.count(func.sum(func.case(DatasetEvent.id.is_not(None), 1, else_=0))).label(
+                        "total_updates"
+                    ),
                 )
-                .outerjoin(DatasetEvent, DatasetEvent.dataset_id == 
DatasetModel.id)
+                .join(DatasetEvent, DatasetEvent.dataset_id == 
DatasetModel.id, isouter=not has_event_filters)

Review Comment:
   and with event filters we do inner join, so that no dataset returned when no 
event subject to filters



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