https://github.com/apache/airflow/blob/main/airflow/cli/commands/task_command.py#L145
TaskFail.dag_id == dag.dag_id,
                DagRun.execution_date >= min_date,
                DagRun.execution_date <= base_date,
            )
        )
        if dag.partial:
            ti_fails = ti_fails.where(TaskFail.task_id.in_([t.task_id for t in dag.tasks]))
        ti_fails = session.scalars(ti_fails)
        fails_totals: dict[tuple[str, str, str], int] = defaultdict(int)
        for failed_task_instance in ti_fails:
            dict_key = (
                failed_task_instance.dag_id,
                failed_task_instance.task_id,
                failed_task_instance.run_id,
            )
            if failed_task_instance.duration:
                fails_totals[dict_key] += failed_task_instance.duration
        
        def grouping_key(ti: TaskInstance):
            return ti.dag_id, ti.task_id, ti.run_id
        mapped_tis = set()
        for _, group in itertools.groupby(sorted(task_instances, key=grouping_key), key=grouping_key):
            tis = list(group)
            duration = sum(x.duration for x in tis if x.duration)
            if duration:
                first_ti = tis[0]
                if first_ti.map_index >= 0:
                    mapped_tis.add(first_ti.task_id)
                date_time = wwwutils.epoch(first_ti.execution_date)
                x_points[first_ti.task_id].append(date_time)