You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "SavingFrame (via GitHub)" <gi...@apache.org> on 2025/07/02 21:54:30 UTC

[PR] Add DAG calendar view endpoint [airflow]

SavingFrame opened a new pull request, #52748:
URL: https://github.com/apache/airflow/pull/52748

   Hello everyone!
   
   This PR adds a new DAG calendar view endpoint that provides scheduling information in a calendar format. This endpoint returns the calendar that existed in Airflow 2.x but provides additional functionality. The new endpoint includes filtering by `logical_date` and the ability to choose granularity, allowing users to customize their calendar view based on specific time periods and detail levels.
   
   ## Changes in this PR:
   - Create service file that processes historical DagRuns and presumes queued runs
   - Add UI endpoint
   - Update Swagger documentation
   - Add tests for different options of this endpoint
   
   ## How was this patch tested?
   
   - Added comprehensive unit tests for the calendar endpoint
   - Tests cover various scenarios including date filtering, granularity options, and DAG selection
   - All existing tests continue to pass
   - Static code checks and pre-commit hooks pass
   
   ## API Details
   
   **Endpoint:** `GET /ui/calendar/{dag_id}`
   
   **Path Parameters:**
   - `dag_id` (string, required): The DAG ID
   
   **Query Parameters:**
   - `granularity` (string, optional): Time granularity - `"hourly"` or `"daily"` (default: `"daily"`)
   - `logical_date_gte` (datetime, optional): Start date for filtering (ISO 8601 format)
   - `logical_date_lte` (datetime, optional): End date for filtering (ISO 8601 format)
   
   **Response Format:**
   Returns an array of `CalendarTimeRangeResult` objects with the following structure:
   
   ```json
   [
     {
       "datetime": "2024-01-15 00:00:00",
       "state": "success",
       "count": 5
     },
     {
       "datetime": "2024-01-15 00:00:00",
       "state": "running",
       "count": 2
     },
     {
       "datetime": "2024-01-16 00:00:00",
       "state": "planned",
       "count": 7
     }
   ]
   ```
   
   **Response Fields:**
   - `datetime`: The timestamp for the calendar entry
   - `state`: Task state - one of `"queued"`, `"running"`, `"success"`, `"failed"`, or `"planned"`
   - `count`: Number of task instances in this state at the given time
   
   ## Related Links
   - [[Discussion](https://github.com/apache/airflow/discussions/50907)](https://github.com/apache/airflow/discussions/50907)
   - [[Reference PR](https://github.com/apache/airflow/pull/37988)](https://github.com/apache/airflow/pull/37988) that provided the main logic
   - [[Specific changes](https://github.com/apache/airflow/pull/37988/files#diff-917b70d2661fae8322c538a4f60b9d4ba755556036fe0c527eb0411a6ac60f2eL2841)](https://github.com/apache/airflow/pull/37988/files#diff-917b70d2661fae8322c538a4f60b9d4ba755556036fe0c527eb0411a6ac60f2eL2841)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "SavingFrame (via GitHub)" <gi...@apache.org>.
SavingFrame commented on code in PR #52748:
URL: https://github.com/apache/airflow/pull/52748#discussion_r2183426443


##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/calendar.py:
##########
@@ -0,0 +1,321 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import collections
+import datetime
+from collections.abc import Iterator
+from typing import Literal, cast
+
+import sqlalchemy as sa
+import structlog
+from croniter.croniter import croniter
+from pendulum import DateTime
+from sqlalchemy.engine import Row
+from sqlalchemy.orm import Session
+
+from airflow.api_fastapi.common.parameters import RangeFilter
+from airflow.api_fastapi.core_api.datamodels.ui.calendar import CalendarTimeRangeResult
+from airflow.models.dag import DAG
+from airflow.models.dagrun import DagRun
+from airflow.timetables._cron import CronMixin
+from airflow.timetables.base import DataInterval, TimeRestriction
+from airflow.timetables.simple import ContinuousTimetable
+from airflow.utils import timezone
+
+log = structlog.get_logger(logger_name=__name__)
+
+
+class CalendarService:
+    """Service class for calendar-related operations."""
+
+    MAX_PLANNED_RUNS: int = 2000
+
+    def get_calendar_data(
+        self,
+        dag_id: str,
+        session: Session,
+        dag: DAG,
+        logical_date: RangeFilter,
+        granularity: Literal["hourly", "daily"] = "daily",
+    ) -> list[CalendarTimeRangeResult]:
+        """
+        Get calendar data for a DAG including historical and planned runs.
+
+        Args:
+            dag_id: The DAG ID
+            session: Database session
+            dag: The DAG object
+            logical_date: Date range filter
+            granularity: Time granularity ("hourly" or "daily")
+
+        Returns:
+            List of calendar time range results
+        """
+        historical_data, raw_dag_states = self._get_historical_dag_runs(
+            dag_id,
+            session,
+            logical_date,
+            granularity,
+        )
+
+        planned_data = self._get_planned_dag_runs(dag, raw_dag_states, logical_date, granularity)
+
+        return historical_data + planned_data
+
+    def _get_historical_dag_runs(
+        self,
+        dag_id: str,
+        session: Session,
+        logical_date: RangeFilter,
+        granularity: Literal["hourly", "daily"],
+    ) -> tuple[list[CalendarTimeRangeResult], list[Row]]:
+        """Get historical DAG runs from the database."""
+        dialect = session.bind.dialect.name
+
+        time_expression = self._get_time_truncation_expression(DagRun.logical_date, granularity, dialect)
+
+        select_stmt = (
+            sa.select(
+                time_expression.label("datetime"),
+                DagRun.state,
+                sa.func.max(DagRun.data_interval_start).label("data_interval_start"),
+                sa.func.max(DagRun.data_interval_end).label("data_interval_end"),
+                sa.func.count("*").label("count"),
+            )
+            .where(DagRun.dag_id == dag_id)
+            .group_by(time_expression, DagRun.state)
+            .order_by(time_expression.asc())
+        )
+
+        select_stmt = logical_date.to_orm(select_stmt)
+        dag_states = session.execute(select_stmt).all()
+
+        calendar_results = [
+            CalendarTimeRangeResult(
+                # ds.datetime in sqlite and mysql is a string, in postgresql it is a datetime
+                datetime=ds.datetime.replace(tzinfo=None)

Review Comment:
   Okay, it was a point i was doubt about. Now I always return datetime in UTC format. My assumption that we always have logical_date in the  UTC in any database, so we can use `date()` function and then convert it into UTC. The do the same with hourly granularity.
   
   Thank you a lot for reviewing. All comments are fixed



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #52748:
URL: https://github.com/apache/airflow/pull/52748#issuecomment-3045192118

   #protm


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #52748:
URL: https://github.com/apache/airflow/pull/52748#issuecomment-3029427582

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "SavingFrame (via GitHub)" <gi...@apache.org>.
SavingFrame commented on PR #52748:
URL: https://github.com/apache/airflow/pull/52748#issuecomment-3036265751

   > Just a couple of Nit.
   > 
   > Thanks for the PR, I think it's a good start to iterate on. Since it's a UI endpoint we are free to modify this as we see fit.
   
   Thank you. Everything is fixed.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #52748:
URL: https://github.com/apache/airflow/pull/52748#issuecomment-3049328830

   Great work! As I said in another thread, I love the hourly or daily granularity. I'm excited to make both a monthly and a weekly calendar view.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun merged PR #52748:
URL: https://github.com/apache/airflow/pull/52748


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #52748:
URL: https://github.com/apache/airflow/pull/52748#discussion_r2185324980


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py:
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+from pydantic import BaseModel
+
+from airflow.utils.state import DagRunState
+
+
+class CalendarTimeRangeDagRuns(BaseModel):
+    """Represents a summary of DAG runs for a specific calendar time range."""
+
+    date: datetime
+    state: Literal[
+        DagRunState.QUEUED,
+        DagRunState.RUNNING,
+        DagRunState.SUCCESS,
+        DagRunState.FAILED,
+        "planned",
+    ]
+    count: int
+
+
+class CalendarTimeRangeDagRunsResponse(BaseModel):

Review Comment:
   ```suggestion
   class CalendarTimeRangeCollectionResponse(BaseModel):
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py:
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+from pydantic import BaseModel
+
+from airflow.utils.state import DagRunState
+
+
+class CalendarTimeRangeDagRuns(BaseModel):

Review Comment:
   ```suggestion
   class CalendarTimeRangeResponse(BaseModel):
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #52748:
URL: https://github.com/apache/airflow/pull/52748#discussion_r2182365615


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py:
##########
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+from pydantic import BaseModel
+
+from airflow.utils.state import DagRunState
+
+
+class CalendarTimeRangeResult(BaseModel):
+    """Task Instance Summary model for the Grid UI."""

Review Comment:
   Wrong doc string



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/calendar.py:
##########
@@ -0,0 +1,82 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Annotated, Literal
+
+from fastapi import Depends
+
+from airflow.api_fastapi.auth.managers.models.resource_details import DagAccessEntity
+from airflow.api_fastapi.common.dagbag import DagBagDep
+from airflow.api_fastapi.common.db.common import SessionDep
+from airflow.api_fastapi.common.parameters import RangeFilter, datetime_range_filter_factory
+from airflow.api_fastapi.common.router import AirflowRouter
+from airflow.api_fastapi.core_api.datamodels.ui.calendar import CalendarTimeRangeResult
+from airflow.api_fastapi.core_api.security import requires_access_dag
+from airflow.api_fastapi.core_api.services.ui.calendar import CalendarService
+from airflow.models.dagrun import DagRun
+
+calendar_router = AirflowRouter(prefix="/calendar", tags=["Calendar"])
+
+
+@calendar_router.get(
+    "/{dag_id}",
+    dependencies=[
+        Depends(
+            requires_access_dag(
+                method="GET",
+                access_entity=DagAccessEntity.TASK_INSTANCE,
+            )
+        ),
+        Depends(
+            requires_access_dag(
+                method="GET",
+                access_entity=DagAccessEntity.RUN,
+            )
+        ),
+    ],
+)
+def get_calendar(
+    dag_id: str,
+    session: SessionDep,
+    dag_bag: DagBagDep,
+    logical_date: Annotated[RangeFilter, Depends(datetime_range_filter_factory("logical_date", DagRun))],
+    granularity: Literal["hourly", "daily"] = "daily",
+) -> list[CalendarTimeRangeResult]:
+    """
+    Get calendar data for a DAG including historical and planned runs.
+
+    Args:
+        dag_id: The DAG ID
+        session: Database session
+        dag_bag: DAG bag dependency
+        logical_date: Date range filter
+        granularity: Time granularity ("hourly" or "daily")
+
+    Returns:
+        List of calendar time range results

Review Comment:
   You can remove, this is already documented in swagger from the params



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py:
##########
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+from pydantic import BaseModel
+
+from airflow.utils.state import DagRunState
+
+
+class CalendarTimeRangeResult(BaseModel):

Review Comment:
   Can you follow the naming convention of other  datamodles please. (Response vs Body)
   
   
   (Collection, with `total_entries`, even if this endpoint is not paginated)



##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/calendar.py:
##########
@@ -0,0 +1,321 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import collections
+import datetime
+from collections.abc import Iterator
+from typing import Literal, cast
+
+import sqlalchemy as sa
+import structlog
+from croniter.croniter import croniter
+from pendulum import DateTime
+from sqlalchemy.engine import Row
+from sqlalchemy.orm import Session
+
+from airflow.api_fastapi.common.parameters import RangeFilter
+from airflow.api_fastapi.core_api.datamodels.ui.calendar import CalendarTimeRangeResult
+from airflow.models.dag import DAG
+from airflow.models.dagrun import DagRun
+from airflow.timetables._cron import CronMixin
+from airflow.timetables.base import DataInterval, TimeRestriction
+from airflow.timetables.simple import ContinuousTimetable
+from airflow.utils import timezone
+
+log = structlog.get_logger(logger_name=__name__)
+
+
+class CalendarService:
+    """Service class for calendar-related operations."""
+
+    MAX_PLANNED_RUNS: int = 2000
+
+    def get_calendar_data(
+        self,
+        dag_id: str,
+        session: Session,
+        dag: DAG,
+        logical_date: RangeFilter,
+        granularity: Literal["hourly", "daily"] = "daily",
+    ) -> list[CalendarTimeRangeResult]:
+        """
+        Get calendar data for a DAG including historical and planned runs.
+
+        Args:
+            dag_id: The DAG ID
+            session: Database session
+            dag: The DAG object
+            logical_date: Date range filter
+            granularity: Time granularity ("hourly" or "daily")
+
+        Returns:
+            List of calendar time range results
+        """
+        historical_data, raw_dag_states = self._get_historical_dag_runs(
+            dag_id,
+            session,
+            logical_date,
+            granularity,
+        )
+
+        planned_data = self._get_planned_dag_runs(dag, raw_dag_states, logical_date, granularity)
+
+        return historical_data + planned_data
+
+    def _get_historical_dag_runs(
+        self,
+        dag_id: str,
+        session: Session,
+        logical_date: RangeFilter,
+        granularity: Literal["hourly", "daily"],
+    ) -> tuple[list[CalendarTimeRangeResult], list[Row]]:
+        """Get historical DAG runs from the database."""
+        dialect = session.bind.dialect.name
+
+        time_expression = self._get_time_truncation_expression(DagRun.logical_date, granularity, dialect)
+
+        select_stmt = (
+            sa.select(
+                time_expression.label("datetime"),
+                DagRun.state,
+                sa.func.max(DagRun.data_interval_start).label("data_interval_start"),
+                sa.func.max(DagRun.data_interval_end).label("data_interval_end"),
+                sa.func.count("*").label("count"),
+            )
+            .where(DagRun.dag_id == dag_id)
+            .group_by(time_expression, DagRun.state)
+            .order_by(time_expression.asc())
+        )
+
+        select_stmt = logical_date.to_orm(select_stmt)
+        dag_states = session.execute(select_stmt).all()
+
+        calendar_results = [
+            CalendarTimeRangeResult(
+                # ds.datetime in sqlite and mysql is a string, in postgresql it is a datetime
+                datetime=ds.datetime.replace(tzinfo=None)

Review Comment:
   ```suggestion
                   datetime=ds.datetime.replace(tzinfo=None)
   ```
   
   Why setting the tzinfo at None like this? (If there is a tzinfo this will actually be wrong, and the AIP should return tz aware datetime)



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py:
##########
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+from pydantic import BaseModel
+
+from airflow.utils.state import DagRunState
+
+
+class CalendarTimeRangeResult(BaseModel):
+    """Task Instance Summary model for the Grid UI."""
+
+    datetime: datetime

Review Comment:
   nit: I think we should keep 'date' even if its a datetime. (start_date, end_date are all called date but they are actually datetime), just for consistencey



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add DAG calendar view endpoint [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #52748:
URL: https://github.com/apache/airflow/pull/52748#issuecomment-3045172797

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org