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 JobCount method to MonitoringApi to get count of jobs in any state #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/Hangfire.Core/Storage/IMonitoringApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public interface IMonitoringApi
JobList<FailedJobDto> FailedJobs(int from, int count);
JobList<DeletedJobDto> DeletedJobs(int from, int count);

long JobCount(string stateName);
long ScheduledCount();
long EnqueuedCount(string queue);
long FetchedCount(string queue);
Expand Down
1 change: 1 addition & 0 deletions src/Hangfire.Core/Storage/JobStorageMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public virtual JobList<AwaitingJobDto> AwaitingJobs(int from, int count)
throw JobStorageFeatures.GetNotSupportedException(JobStorageFeatures.Monitoring.AwaitingJobs);
}

public abstract long JobCount(string stateName);
public abstract long ScheduledCount();
public abstract long EnqueuedCount(string queue);
public abstract long FetchedCount(string queue);
Expand Down
5 changes: 5 additions & 0 deletions src/Hangfire.SqlServer/SqlServerMonitoringApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public SqlServerMonitoringApi([NotNull] SqlServerStorage storage, int? jobListLi
_jobListLimit = jobListLimit;
}

public override long JobCount(string stateName)
{
return UseConnection(connection => GetNumberOfJobsByStateName(connection, stateName));
}

public override long ScheduledCount()
{
return UseConnection(connection =>
Expand Down