Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Simplify code in www #33270

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3251,8 +3251,7 @@ def duration(self, dag_id: str, session: Session = NEW_SESSION):
y=scale_time_units(cumulative_y[task_id], cum_y_unit),
)

dates = sorted({ti.execution_date for ti in task_instances})
max_date = max(ti.execution_date for ti in task_instances) if dates else None
max_date = max((ti.execution_date for ti in task_instances), default=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Begs the question why we needed to sort the dates in the first place. Leftover code maybe, who knows.


session.commit()

Expand Down Expand Up @@ -3350,8 +3349,7 @@ def tries(self, dag_id: str, session: Session = NEW_SESSION):
if x_points:
chart.add_serie(name=task.task_id, x=x_points, y=y_points)

tries = sorted({ti.try_number for ti in tis})
max_date = max(ti.execution_date for ti in tis) if tries else None
max_date = max((ti.execution_date for ti in tis), default=None)
chart.create_y_axis("yAxis", format=".02f", custom_format=False, label="Tries")
chart.axislist["yAxis"]["axisLabelDistance"] = "-15"

Expand Down Expand Up @@ -3874,7 +3872,7 @@ def datasets_summary(self):
updated_before = _safe_parse_datetime(request.args.get("updated_before"), allow_empty=True)

# Check and clean up query parameters
limit = 50 if limit > 50 else limit
limit = min(50, limit)

uri_pattern = uri_pattern[:4000]

Expand Down