bugraoz93 commented on code in PR #44332: URL: https://github.com/apache/airflow/pull/44332#discussion_r1875051563
########## airflow/api_fastapi/core_api/routes/ui/service/grid.py: ########## @@ -0,0 +1,205 @@ +# 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 operator +from functools import cache + +from typing_extensions import Any + +from airflow import DAG +from airflow.api_fastapi.common.db.common import SessionDep +from airflow.api_fastapi.common.parameters import ( + BaseParam, + SortParam, +) +from airflow.api_fastapi.core_api.datamodels.ui.grid import ( + GridTaskInstanceSummary, +) +from airflow.configuration import conf +from airflow.exceptions import AirflowConfigException +from airflow.models import DagRun, MappedOperator +from airflow.models.baseoperator import BaseOperator +from airflow.models.taskmap import TaskMap +from airflow.utils.state import TaskInstanceState +from airflow.utils.task_group import MappedTaskGroup, TaskGroup + + +def get_dag_run_sort_param(dag: DAG) -> BaseParam: + """ + Get the Sort Param for the DAG Run. + + Data interval columns are NULL for runs created before 2.3, but SQL's + NULL-sorting logic would make those old runs always appear first. In a + perfect world we'd want to sort by ``get_run_data_interval()``, but that's + not efficient, so instead if the run_ordering is data_interval_start or data_interval_end, + we sort by logical_date instead. + + :param dag: DAG + + :return: Sort Param + """ + for name in dag.timetable.run_ordering: + if name in ("data_interval_start", "data_interval_end"): + return SortParam( + allowed_attrs=["logical_date", "data_interval_start", "data_interval_end"], model=DagRun Review Comment: It is now created once and returns the `set_value` accordingly -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org