tirkarthi commented on code in PR #44043:
URL: https://github.com/apache/airflow/pull/44043#discussion_r1843080923


##########
airflow/api_fastapi/core_api/routes/ui/dashboard.py:
##########
@@ -49,12 +49,18 @@ def historical_metrics(
     session: Annotated[Session, Depends(get_session)],
 ) -> HistoricalMetricDataResponse:
     """Return cluster activity historical metrics."""
+    if start_date is None:
+        raise HTTPException(
+            status_code=status.HTTP_400_BAD_REQUEST,
+            detail="start_date parameter is required in the request",
+        )
+
     # DagRuns
     dag_run_types = session.execute(
         select(DagRun.run_type, func.count(DagRun.run_id))
         .where(
             DagRun.start_date >= start_date,
-            func.coalesce(DagRun.end_date, timezone.utcnow()) <= end_date,
+            func.coalesce(DagRun.end_date, timezone.utcnow()) <= 
func.coalesce(end_date, timezone.utcnow()),

Review Comment:
   `timezone.utcnow()` can be just defined once at the top of the function to 
avoid different values due to multiple calls.



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