public IObservable <ImmutableList <BranchGroupCompleteData> > AllBranchesHierarchy()
 {
     return((
                // TODO - should be more efficient with SQL here.
                branchSettings.GetAllDownstreamBranches()
                .SelectMany(allBranches =>
                            allBranches.ToObservable().SelectMany(async branch => new BranchGroupCompleteData(branch)
     {
         DownstreamBranchGroups = (await branchSettings.GetDownstreamBranches(branch.GroupName).FirstOrDefaultAsync()).Select(b => b.GroupName).ToImmutableList()
     }).ToArray()
                            )
                .Select(branches => branches.ToImmutableList())
                .CombineLatest(
                    repositoryState.RemoteBranches(),
                    (first, second) => new { first, second }
                    )
                .SelectMany(async param =>
                            (await GroupBranches(param.first, param.second, ToDefaultBranchGroup))
                            .OrderBy(a => a.GroupName)
                            .Select(a => new BranchGroupCompleteData(a)
     {
         DownstreamBranchGroups = a.DownstreamBranchGroups ?? ImmutableList <string> .Empty,
     })
                            .ToImmutableList()
                            )
                ).FirstAsync());
 }
Esempio n. 2
0
 public async Task <string[]> DownstreamBranches(string branchName)
 {
     return(await branchSettings.GetDownstreamBranches(branchName).FirstAsync());
 }