pierrejeambrun commented on code in PR #73684:
URL: https://github.com/apache/airflow/pull/73684#discussion_r4105380976
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/job.py:
##########
@@ -106,6 +106,11 @@ def get_jobs(
"""Get all jobs."""
base_select =
select(Job).order_by(Job.latest_heartbeat.desc()).options(joinedload(Job.dag_model))
+ if is_alive is not None:
+ # Filter in SQL rather than on the fetched page so total_entries and
the page agree.
+ alive = Job.alive_filter()
+ base_select = base_select.where(alive if is_alive else ~alive)
+
Review Comment:
This is not how filters should be implemented.
We should create an `IsAliveFilter` following the common parameters
interface we have in the app.
And then provide the filter to `paginated_select`.
The custom impl for `alive_filter` wouldn't leak on the model (job
definition).
The view wouldn't implement any custom logic for one specific filter while
all others are properly handled through the pagination utility.
--
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]