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

Dashboard: Delete selected jobs? #1625

Open
enkelmedia opened this issue Feb 27, 2020 · 5 comments
Open

Dashboard: Delete selected jobs? #1625

enkelmedia opened this issue Feb 27, 2020 · 5 comments

Comments

@enkelmedia
Copy link

Today, as far as I know, one would have to go to the details-view for each job and click "Delete" to remove the job. But I'm thinking that it might be a good idea to add a "delete"-button to the overview as well?

Maybe the placement in this example might not be so good but I just wanted to share the idea.

hangfire delete from dashboard example

Any chance this is something that can be considered? I could maybe come up with a PR if it's wanted.

All the best!

@odinserj
Copy link
Member

Succeeded jobs will be expired automatically after 24 hours by default (the same behavior as with background jobs in the Deleted state), so no need to do anything. Custom retention time can be configured even for individual background jobs by using an extension filter as written here. Also retention time can be configured globally by calling the WithJobExpirationTimeout method called just after the UseXXXStorage (where XXX is a particular storage, if this method returns IGlobalConfiguration<JobStorage> instance).

config.UseXXXStorage().WithJobExpirationTimeout(TimeSpan.FromHours(4));

@sumitgupta1225
Copy link

Hi @enkelmedia, @odinserj

We have raised the PR #1957 for this issue.

@odinserj
Copy link
Member

Hi @sumitgupta1225 and thank you for your PR. However could you tell me what is the purpose of the PR – background jobs in both Succeeded and Deleted states use the same expiration policy described in my comment above, so we don't need to anything with Succeeded jobs – they will disappear after expiration timeout is elapsed (24 hours by default, but configurable as shown above).

@BRekha-TPG
Copy link

@odinserj Reason why we found this useful is, as sometime user want to see the relevant jobs on top even when they are succeeded( like in our case , we only wanted to see the SQL jobs on top for some comparison and around 100 jobs was running each hour, so if could have selected one type of job and remove), succeeded jobs gives the capability to remove them one by one, but removing in bulk can be a good option

@odinserj
Copy link
Member

@BRekha-TPG if you just want to avoid listing some job method in the succeeded list, you can just create the following state filter and apply it to the required method, and everything will be handled automatically without trying to delete jobs manually. I'm afraid this is a specific use case for decoration purposes and the presence of the "Delete" button can be misleading because one may think that it will remove job from the storage immediately.

public class DeleteOnCompletionAttribute : JobFilterAttribute, IElectStateFilter
{
    public void OnStateElection(ElectStateContext context)
    {
        if (context.CandidateState is SucceededState)
        {
            context.CandidateState = new DeletedState
            {
                Reason = "DeleteOnCompletion applied"
            };
        }
    }
}
[DeleteOnCompletion]
public void MyJobThatShouldNotBeVisibleInTheSucceededList() {}

// No attribute applied
public void MyAnotherJobThatShouldBeVisible() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants