Example #1
0
        public async Task <IActionResult> GetFlowGraphAsync(
            int channelId = 0,
            bool includeDisabledSubscriptions = false,
#pragma warning disable API0001 // Versioned API methods should not expose non-versioned types.
            IEnumerable <string> includedFrequencies = default,
#pragma warning restore API0001 // Versioned API methods should not expose non-versioned types.
            bool includeBuildTimes = false,
            int days           = 7,
            bool includeArcade = true)
        {
            var barOnlyRemote = await _remoteFactory.GetBarOnlyRemoteAsync(Logger);

            var flowGraph = await barOnlyRemote.GetDependencyFlowGraphAsync(
                channelId,
                days,
                includeArcade,
                includeBuildTimes,
                includeDisabledSubscriptions,
                includedFrequencies.ToList());

            // Convert flow graph to correct return type
            return(Ok(FlowGraph.Create(flowGraph)));
        }
Example #2
0
        public async Task <IActionResult> GetFlowGraphAsync(
            int channelId = 0,
            bool includeDisabledSubscriptions = false,
#pragma warning disable API0001 // Versioned API methods should not expose non-versioned types.
            IEnumerable <string> includedFrequencies = default,
#pragma warning restore API0001 // Versioned API methods should not expose non-versioned types.
            bool includeBuildTimes = false,
            int days           = 7,
            bool includeArcade = true)
        {
            var barOnlyRemote = await _remoteFactory.GetBarOnlyRemoteAsync(Logger);

            Microsoft.DotNet.Maestro.Client.Models.Channel engLatestChannel = await barOnlyRemote.GetChannelAsync(EngLatestChannelId);

            Microsoft.DotNet.Maestro.Client.Models.Channel eng3Channel = await barOnlyRemote.GetChannelAsync(Eng3ChannelId);

            List <Microsoft.DotNet.Maestro.Client.Models.DefaultChannel> defaultChannels = (await barOnlyRemote.GetDefaultChannelsAsync()).ToList();

            if (includeArcade)
            {
                if (engLatestChannel != null)
                {
                    defaultChannels.Add(
                        new Microsoft.DotNet.Maestro.Client.Models.DefaultChannel(0, "https://github.com/dotnet/arcade", true)
                    {
                        Branch  = "master",
                        Channel = engLatestChannel
                    }
                        );
                }

                if (eng3Channel != null)
                {
                    defaultChannels.Add(
                        new Microsoft.DotNet.Maestro.Client.Models.DefaultChannel(0, "https://github.com/dotnet/arcade", true)
                    {
                        Branch  = "release/3.x",
                        Channel = eng3Channel
                    }
                        );
                }
            }

            List <Microsoft.DotNet.Maestro.Client.Models.Subscription> subscriptions = (await barOnlyRemote.GetSubscriptionsAsync()).ToList();

            // Build, then prune out what we don't want to see if the user specified
            // channels.
            DependencyFlowGraph flowGraph = await DependencyFlowGraph.BuildAsync(defaultChannels, subscriptions, barOnlyRemote, days);

            IEnumerable <string> frequencies = includedFrequencies == default || includedFrequencies.Count() == 0 ?
                                               new string[] { "everyWeek", "twiceDaily", "everyDay", "everyBuild", "none", } :
            includedFrequencies;

            Microsoft.DotNet.Maestro.Client.Models.Channel targetChannel = null;

            if (channelId != 0)
            {
                targetChannel = await barOnlyRemote.GetChannelAsync((int)channelId);
            }

            if (targetChannel != null)
            {
                flowGraph.PruneGraph(
                    node => DependencyFlowGraph.IsInterestingNode(targetChannel.Name, node),
                    edge => DependencyFlowGraph.IsInterestingEdge(edge, includeDisabledSubscriptions, frequencies));
            }

            if (includeBuildTimes)
            {
                flowGraph.MarkBackEdges();
                flowGraph.CalculateLongestBuildPaths();
                flowGraph.MarkLongestBuildPath();
            }

            // Convert flow graph to correct return type
            return(Ok(FlowGraph.Create(flowGraph)));
        }