Get branch details and sort by modification date
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m45s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m45s
This commit is contained in:
parent
1cc884bec3
commit
5966641b75
1 changed files with 12 additions and 5 deletions
|
@ -5,15 +5,22 @@ using Website.Data;
|
|||
|
||||
namespace Website.ViewComponents {
|
||||
public class ProjectNavigationViewComponent :ViewComponent {
|
||||
private readonly IGitApi _api;
|
||||
private readonly IGitApi _gitApi;
|
||||
|
||||
public ProjectNavigationViewComponent(IGitApi api) {
|
||||
_api = api;
|
||||
public ProjectNavigationViewComponent(IGitApi gitApi) {
|
||||
_gitApi = gitApi;
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync() {
|
||||
var repositories = await _api.GetRepositories("rob");
|
||||
return View(repositories.Take(5));
|
||||
var repos = await _gitApi.GetRepositories("rob");
|
||||
|
||||
var branchTasks = repos.Select(repo => _gitApi.GetBranches("rob", repo));
|
||||
var branchResults = await Task.WhenAll(branchTasks);
|
||||
var branches = branchResults.SelectMany(branch => branch);
|
||||
var sortedBranches = branches.OrderByDescending(branch => branch.Commit.Timestamp);
|
||||
var sortedRepos = sortedBranches.DistinctBy(branch => branch.Repository).Select(branch => branch.Repository);
|
||||
|
||||
return View(sortedRepos.Take(5));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue