Skip to content

Commit df8a256

Browse files
parithoncsharpfritz
authored andcommitted
Exclude GitHub contributors. Fixes #188 (#189)
Adds the ability for you to exclude GitHub contributors within the appsettings.json file.
1 parent 2d2616d commit df8a256

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Fritz.StreamTools/Models/GitHubConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Microsoft.AspNetCore.Mvc;
2+
using System.Collections;
3+
using System.Collections.Generic;
24
using System.ComponentModel.DataAnnotations;
35

46
namespace Fritz.StreamTools.Models
@@ -15,7 +17,7 @@ public class GitHubConfiguration
1517
[Remote(action: "VerifyRepository", controller: "GitHub", AdditionalFields = nameof(RepositoryOwner))]
1618
public string RepositoryName { get; set; }
1719

18-
public string ExcludeUser { get; set;} = "csharpfritz";
20+
public ICollection<string> ExcludeUsers { get; set; }
1921

2022
public string RepositoryCsv { get; set; } = "csharpfritz/Fritz.StreamTools,csharpfritz/CoreWiki";
2123

Fritz.StreamTools/Models/GitHubRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private async Task<List<GitHubInformation>> FetchContributersFromGithub(string r
5454
return outModel;
5555
}
5656
model.TopEverContributors.AddRange(
57-
contributors.Where(c => c.Total > 0 && c.Author.Login != Configuration.ExcludeUser)
57+
contributors.Where(c => c.Total > 0 && !Configuration.ExcludeUsers.Contains(c.Author.Login))
5858
.OrderByDescending(c => c.Total)
5959
.Take(5)
6060
.Select(c => new GitHubContributor()
@@ -71,7 +71,7 @@ private async Task<List<GitHubInformation>> FetchContributersFromGithub(string r
7171
Commits = c.Weeks.Where(w => w.Week >= lastMonth)
7272
.Sum(e => e.Commits)
7373
})
74-
.Where(c => c.Commits > 0 && c.Author != Configuration.ExcludeUser)
74+
.Where(c => c.Commits > 0 && !Configuration.ExcludeUsers.Contains(c.Author))
7575
.OrderByDescending(c => c.Commits)
7676
.Take(5));
7777
model.TopWeekContributors.AddRange(
@@ -81,7 +81,7 @@ private async Task<List<GitHubInformation>> FetchContributersFromGithub(string r
8181
Author = c.Author.Login,
8282
Commits = c.Weeks.Last().Commits
8383
})
84-
.Where(c => c.Commits > 0 && c.Author != Configuration.ExcludeUser)
84+
.Where(c => c.Commits > 0 && !Configuration.ExcludeUsers.Contains(c.Author))
8585
.OrderByDescending(c => c.Commits)
8686
.Take(5));
8787
outModel.Add(model);

Fritz.StreamTools/appsettings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
},
6969
"GitHub": {
7070
"RepositoryName": "Fritz.StreamTools",
71-
"RepositoryOwner": "csharpfritz"
71+
"RepositoryOwner": "csharpfritz",
72+
"ExcludeUsers": [
73+
"csharpfritz",
74+
"dependabot"
75+
]
7276
}
7377
}

0 commit comments

Comments
 (0)