From 8421832bdb3c0fd36d490df23eb832efd51f3e58 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 11 Jun 2020 16:52:00 -0400 Subject: [PATCH] Add back the extended information for now As a curiosity while exploring https://github.com/octokit/octokit.net/issues/2208 --- src/Konmaripo.Web/Models/ExtendedRepoInformation.cs | 4 +++- src/Konmaripo.Web/Services/GitHubService.cs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Konmaripo.Web/Models/ExtendedRepoInformation.cs b/src/Konmaripo.Web/Models/ExtendedRepoInformation.cs index c5ed479..c635aaa 100644 --- a/src/Konmaripo.Web/Models/ExtendedRepoInformation.cs +++ b/src/Konmaripo.Web/Models/ExtendedRepoInformation.cs @@ -9,12 +9,14 @@ namespace Konmaripo.Web.Models public class ExtendedRepoInformation { public long RepoId { get; } + public int NumberOfWatchers { get; } public int ViewsInTheLast14Days { get; } public int CommitActivityInTheLast4Weeks { get; } - public ExtendedRepoInformation(long repoId, int viewsInTheLast14Days, int commitActivityInTheLast4Weeks) + public ExtendedRepoInformation(long repoId, int numberOfWatchers, int viewsInTheLast14Days, int commitActivityInTheLast4Weeks) { RepoId = repoId; + NumberOfWatchers = numberOfWatchers; ViewsInTheLast14Days = viewsInTheLast14Days; CommitActivityInTheLast4Weeks = commitActivityInTheLast4Weeks; } diff --git a/src/Konmaripo.Web/Services/GitHubService.cs b/src/Konmaripo.Web/Services/GitHubService.cs index da2e319..088fce9 100644 --- a/src/Konmaripo.Web/Services/GitHubService.cs +++ b/src/Konmaripo.Web/Services/GitHubService.cs @@ -30,11 +30,12 @@ public async Task> GetRepositoriesForOrganizationAsync() public async Task GetExtendedRepoInformationFor(long repoId) { + var watchers = await _githubClient.Activity.Watching.GetAllWatchers(repoId); var views = await _githubClient.Repository.Traffic.GetViews(repoId, new RepositoryTrafficRequest(TrafficDayOrWeek.Week)); var commitActivity = await _githubClient.Repository.Statistics.GetCommitActivity(repoId); var commitActivityInLast4Weeks = commitActivity.Activity.OrderByDescending(x => x.WeekTimestamp).Take(4).Sum(x => x.Total); - var extendedRepoInfo = new ExtendedRepoInformation(repoId, views.Count, commitActivityInLast4Weeks); + var extendedRepoInfo = new ExtendedRepoInformation(repoId, watchers.Count, views.Count, commitActivityInLast4Weeks); return extendedRepoInfo; }