Skip to content

Commit

Permalink
Add back the extended information for now
Browse files Browse the repository at this point in the history
As a curiosity while exploring octokit/octokit.net#2208
  • Loading branch information
SeanKilleen committed Jun 11, 2020
1 parent ffd9d20 commit 8421832
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Konmaripo.Web/Models/ExtendedRepoInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Konmaripo.Web/Services/GitHubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public async Task<List<GitHubRepo>> GetRepositoriesForOrganizationAsync()

public async Task<ExtendedRepoInformation> 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;
}
Expand Down

0 comments on commit 8421832

Please sign in to comment.