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

Add more filters to the different job statuses #30

Open
rosa opened this issue Jan 29, 2024 · 13 comments
Open

Add more filters to the different job statuses #30

rosa opened this issue Jan 29, 2024 · 13 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@rosa
Copy link
Member

rosa commented Jan 29, 2024

For example, filter scheduled jobs by scheduled_at time ranges, or finished jobs by finished_at time ranges, or blocked jobs by the block (Blocked by) key. The current filters by queue name and job class are generic and apply to all statuses, but we could have some filters that apply only to certain statuses. The Adapter#supported_filters already takes a JobsRelation as argument, so it can easily return different filters depending on jobs_relation.status.

@rosa rosa added the good first issue Good for newcomers label Jan 29, 2024
@bruno-oliveira
Copy link

I'd like to tackle this one!

@Xeitor
Copy link
Contributor

Xeitor commented Mar 19, 2024

hi @bruno-oliveira, are u still working on this?

@Xeitor
Copy link
Contributor

Xeitor commented Mar 21, 2024

hi @rosa, is it okay if give this a try?

@rosa rosa assigned Xeitor and unassigned bruno-oliveira Mar 22, 2024
@rosa
Copy link
Member Author

rosa commented Mar 22, 2024

@Xeitor sure thing!

@nhorton
Copy link

nhorton commented Mar 25, 2024

One thing that would be awesome here would be if we could filter on a job argument. The basic scenario is that we do a lot of jobs on different accounts, and often we have questions of "what is still running for Account X". Right now we use sidekiq and do something kludgy to access this in the UI, and doing it properly with Mission Control would be really awesome.

@Xeitor
Copy link
Contributor

Xeitor commented Mar 25, 2024

@nhorton: sure, sounds useful, will take a look

@Xeitor
Copy link
Contributor

Xeitor commented Apr 4, 2024

hi @rosa, sorry for the delay, I've been getting myself familiar with the codebase

I was hoping you could help me out with a doubt, I am confused about what you said in the description about using Adapter#supported_filters (a method that seems to no longer exist) for returning filters based on the JobsRelation status, for what I can see, Adapters#supported_job_filters is used for returning filters suppoted natively by the adapter.

@Xeitor
Copy link
Contributor

Xeitor commented Apr 4, 2024

I just realized there already is some logic for raising errors if a filter is set for a non supported job status

example: raise ActiveJob::Errors::QueryError, "Filtering by worker id is not supported for status #{jobs_relation.status}" in lib/active_job/queue_adapters/solid_queue_ext.rb

@Xeitor
Copy link
Contributor

Xeitor commented Apr 4, 2024

I am guessing we could have one hand an error raised if a filter is used for the wrong status (like in the example above) and in the other a method like the one you mention (Adapter#supported_filters) for checking in the views if the filter should be used for the current status

@rosa
Copy link
Member Author

rosa commented Apr 5, 2024

Hey @Xeitor, sorry, my description was from over 2 months ago, and things have changed since then. Adapters#supported_job_filters takes a job_relation as argument and can use that to decide what filters are supported, just like this:

def supported_job_filters(jobs_relation)
if jobs_relation.pending? then [ :queue_name ]
else []
end
end

It takes into account what filters the adapter supports but also the jobs_relation.status.

@Xeitor
Copy link
Contributor

Xeitor commented Apr 5, 2024

hi, no problem, from what I can tell, Adapters#supported_job_filters will return the natively supported filters for the adapter (taking into account the jobs_relation status), for example:

def supported_job_filters(jobs_relation)
if jobs_relation.pending? then [ :queue_name ]
else []
end
end

in the resque adapter :queue_name filter can be performed natively if jobs_relation is pending and it will perform it in memory otherwise, :job_class_name will be performed in memory no matter the jobs_relation status

so I suppose we need another method that tells you if the filter is supported for the status, unless I am missing something

@rosa
Copy link
Member Author

rosa commented Apr 6, 2024

@Xeitor ah yes! Sorry, you're totally correct. Other filters could not be natively supported but are fine if performed in memory. I was getting confused with supported_job_statuses, which has nothing to do 😅

I'll continue the discussion in the PR, ultimately these are all implementation details that might not matter in the end.

@Xeitor
Copy link
Contributor

Xeitor commented Apr 6, 2024

@rosa no problem, thanks for your help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants