Esempio n. 1
0
        public bool TryCreateTimelineQuery(IssueKind kind, GitHubIssueKey issueKey, string text)
        {
            if (TryGetTimelineQuery(issueKey, out var timelineQuery))
            {
                return(false);
            }

            timelineQuery = new ModelTimelineQuery()
            {
                GitHubOrganization = issueKey.Organization,
                GitHubRepository   = issueKey.Repository,
                IssueNumber        = issueKey.Number,
                SearchText         = text
            };

            try
            {
                Context.ModelTimelineQueries.Add(timelineQuery);
                Context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Esempio n. 2
0
 public bool TryGetTimelineQuery(GitHubIssueKey issueKey, [NotNullWhen(true)] out ModelTimelineQuery timelineQuery)
 {
     timelineQuery = Context.ModelTimelineQueries
                     .Where(x =>
                            x.GitHubOrganization == issueKey.Organization &&
                            x.GitHubRepository == issueKey.Repository &&
                            x.IssueNumber == issueKey.Number)
                     .FirstOrDefault();
     return(timelineQuery is object);
 }
Esempio n. 3
0
        private void DoSearchTimeline(
            Build build,
            Timeline timeline,
            ModelBuild modelBuild,
            ModelTimelineQuery modelTimelineQuery)
        {
            var searchText = modelTimelineQuery.SearchText;

            Logger.LogInformation($@"Text: ""{searchText}""");
            if (TriageContextUtil.IsProcessed(modelTimelineQuery, modelBuild))
            {
                Logger.LogInformation($@"Skipping");
                return;
            }

            var count = 0;

            foreach (var result in QueryUtil.SearchTimeline(build, timeline, text: searchText))
            {
                count++;

                var modelTimelineItem = new ModelTimelineItem()
                {
                    TimelineRecordName = result.TimelineRecord.Name,
                    Line               = result.Line,
                    ModelBuild         = modelBuild,
                    ModelTimelineQuery = modelTimelineQuery,
                    BuildNumber        = result.Build.GetBuildKey().Number,
                };
                Context.ModelTimelineItems.Add(modelTimelineItem);
            }

            var modelTimelineQueryComplete = new ModelTimelineQueryComplete()
            {
                ModelTimelineQuery = modelTimelineQuery,
                ModelBuild         = modelBuild,
            };

            Context.ModelTimelineQueryCompletes.Add(modelTimelineQueryComplete);

            try
            {
                Logger.LogInformation($@"Saving {count} jobs");
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.LogError($"Cannot save timeline complete: {ex.Message}");
            }
        }
Esempio n. 4
0
 public bool IsProcessed(ModelTimelineQuery timelineQuery, ModelBuild modelBuild) =>
 Context.ModelTimelineQueryCompletes.Any(x =>
                                         x.ModelTimelineQueryId == timelineQuery.Id &&
                                         x.ModelBuildId == modelBuild.Id);
Esempio n. 5
0
 public static GitHubIssueKey GetGitHubIssueKey(ModelTimelineQuery timelineQuery) =>
 new GitHubIssueKey(timelineQuery.GitHubOrganization, timelineQuery.GitHubRepository, timelineQuery.IssueNumber);