Skip to content

Commit 016a74c

Browse files
committed
#100: Fix for showing dashboard when no tags exist
1 parent 515ec3c commit 016a74c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/FaceIT.Hangfire.Tags.Mongo/FaceIT.Hangfire.Tags.Mongo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
66
<Authors>Erwin Bovendeur</Authors>
77
<Company>2Face-IT B.V.</Company>
8-
<Version>1.9.0</Version>
8+
<Version>1.9.1</Version>
99
<Description>Support for MongoDB for Hangfire.Tags. This separate library is required in order to search for tags, and proper cleanup.</Description>
1010
<Copyright />
1111
<PackageProjectUrl>https://github.com/face-it/Hangfire.Tags</PackageProjectUrl>

src/FaceIT.Hangfire.Tags.Mongo/MongoTagsServiceStorage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override IEnumerable<TagDto> SearchWeightedTags(JobStorage jobStorage, st
6666
var mainQuery = monitoringApi.DbContext.Database.GetCollection<BsonDocument>($"{_options.Prefix}.jobGraph").Aggregate()
6767
.Match(filterBson).As<SetDto>();
6868

69-
var total = mainQuery.Count().Single().Count;
69+
var total = mainQuery.Count().SingleOrDefault()?.Count ?? 0;
7070
var grp = mainQuery.Group(x => x.Value,
7171
x => new TagDto
7272
{
@@ -166,7 +166,7 @@ private static DateTime GetStateDate(SafeDictionary<string, string> stateData, s
166166
private int GetJobCount(HangfireDbContext context, string[] tags, string stateName)
167167
{
168168
var qry = CreateBaseQuery(context, tags, stateName);
169-
return (int) qry.Count().Single().Count;
169+
return (int) (qry.Count().SingleOrDefault()?.Count ?? 0);
170170
}
171171

172172
private JobList<TDto> GetJobs<TDto>(
@@ -322,7 +322,7 @@ public override long GetTagCount(JobStorage jobStorage, string setKey = "tags")
322322
var mainQuery = monitoringApi.DbContext.Database.GetCollection<BsonDocument>($"{_options.Prefix}.jobGraph").Aggregate()
323323
.Match(filterBson).As<SetDto>();
324324

325-
return mainQuery.Count().Single().Count;
325+
return mainQuery.Count().SingleOrDefault()?.Count ?? 0;
326326
}
327327

328328
public override string[] GetTags(JobStorage jobStorage, string jobId)

0 commit comments

Comments
 (0)