henry3260 commented on code in PR #68604:
URL: https://github.com/apache/airflow/pull/68604#discussion_r3444065229


##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/calendar.py:
##########
@@ -357,3 +360,54 @@ def _is_date_in_range(self, dt: datetime, date_filter: 
RangeFilter) -> bool:
             return False
 
         return True
+
+    def get_deadline_calendar_data(
+        self,
+        dag_id: str,
+        session: Session,
+        deadline_time: RangeFilter,
+        granularity: Literal["hourly", "daily"] = "daily",

Review Comment:
   ```suggestion
           self,
           dag_id: str,
           deadline_time: RangeFilter,
           granularity: Literal["hourly", "daily"] = "daily",
           *,
           session: Session,
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/calendar.py:
##########
@@ -357,3 +360,54 @@ def _is_date_in_range(self, dt: datetime, date_filter: 
RangeFilter) -> bool:
             return False
 
         return True
+
+    def get_deadline_calendar_data(
+        self,
+        dag_id: str,
+        session: Session,
+        deadline_time: RangeFilter,
+        granularity: Literal["hourly", "daily"] = "daily",
+    ) -> CalendarDeadlineCollectionResponse:
+        """
+        Get deadline calendar data for a Dag, aggregated by time bucket and 
missed status.
+
+        Args:
+            dag_id: The Dag ID
+            session: Database session
+            deadline_time: Date range filter for deadline_time
+            granularity: Time granularity ("hourly" or "daily")
+
+        Returns:
+            Aggregated deadline counts per time bucket, split by 
missed/pending status
+        """
+        dialect = get_dialect_name(session)
+        time_expression = 
self._get_time_truncation_expression(Deadline.deadline_time, granularity, 
dialect)
+
+        select_stmt = (
+            sa.select(
+                time_expression.label("datetime"),
+                Deadline.missed,
+                sa.func.count("*").label("count"),
+            )
+            .join(Deadline.dagrun)
+            .where(DagRun.dag_id == dag_id)
+            .group_by(time_expression, Deadline.missed)
+            .order_by(time_expression.asc())

Review Comment:
   ```suggestion
               .order_by(time_expression.asc(), Deadline.missed.asc())
   ```



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