Smitaambiger commented on PR #64387:
URL: https://github.com/apache/airflow/pull/64387#issuecomment-4197725933

   Fixes #63715
   
   ## What this PR does
   
   Adds `start_date` and `end_date` query parameters to the Gantt endpoint so
   users can filter the chart to a specific time window. This fixes the
   compressed bar problem when task tries are spread across a large time range.
   
   ## Changes
   
   **Backend** (`gantt.py`):
   - Added `start_date_range` / `end_date_range` query params (aliased as 
`start_date` / `end_date`)
   - SQL filters both `TaskInstance` and `TaskInstanceHistory`
   - Running tasks with NULL `end_date` are always included when filtering by 
`start_date`
   - Returns HTTP 400 when `start_date > end_date`
   
   **Frontend** (`Gantt.tsx`):
   - Date inputs using Chakra UI v3 `Field.Root` + `Field.Label` + 
`Field.ErrorText`
   - Inline validation without `alert()` — error shown in the UI
   - Passes selected range to backend as query params — no client-side filtering
   - Clearing a field works correctly (empty string is not compared)
   
   **i18n** (`common.json`):
   - Added `startDateAfterEndDate` and `endDateBeforeStartDate` translation keys
   
   **Tests** (`test_gantt.py`):
   - Added `test_gantt_with_start_date` — verifies tasks outside range are 
excluded, running tasks always included
   - Added `test_gantt_with_end_date` — verifies tasks starting after end_date 
are excluded
   - Added `test_invalid_date_range_returns_400` — verifies 400 response when 
start > end
   - All 16 tests pass locally in Breeze
   
   ## Behavior
   
   | Scenario | Result |
   |---|---|
   | No filter | Full data shown |
   | `start_date` only | Tasks with `end_date >= start_date` shown; running 
tasks (NULL `end_date`) always included |
   | `end_date` only | Tasks with `start_date <= end_date` shown |
   | Both dates | Tasks within window shown |
   | `start_date > end_date` | HTTP 400 |
   | Invalid dag/run | HTTP 404 |
   
   ## Manual Testing
   
   The feature was validated through unit tests and code-level verification.
   
   * Verified `start_date` filtering excludes tasks outside range
   * Verified `end_date` filtering excludes tasks starting after the range
   * Verified running tasks (`NULL end_date`) are always included
   * Verified invalid range (`start_date > end_date`) returns HTTP 400
   
   All tests pass locally in Breeze.
   
   ### UI Behavior
   
   * Date inputs are rendered above the Gantt chart using Chakra UI `Field.Root`
   * Inline validation prevents invalid date ranges using `Field.ErrorText`
   * Selected date range is passed to backend via query parameters (no 
client-side filtering)
   
   **Note:** UI screenshots are not included as local UI rebuild (Breeze) was 
not available in this environment.
   
   


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