public ModelBuild EnsureBuild(BuildInfo buildInfo) { var modelBuildId = GetModelBuildId(buildInfo.Key); var modelBuild = Context.ModelBuilds .Where(x => x.Id == modelBuildId) .FirstOrDefault(); if (modelBuild is object) { return(modelBuild); } var prKey = buildInfo.PullRequestKey; modelBuild = new ModelBuild() { Id = modelBuildId, ModelBuildDefinitionId = EnsureBuildDefinition(buildInfo.DefinitionInfo).Id, GitHubOrganization = prKey?.Organization, GitHubRepository = prKey?.Repository, PullRequestNumber = prKey?.Number, StartTime = buildInfo.StartTime, FinishTime = buildInfo.FinishTime, BuildNumber = buildInfo.Number, }; Context.ModelBuilds.Add(modelBuild); Context.SaveChanges(); return(modelBuild); }
public static BuildInfo GetBuildInfo(ModelBuild build) => new BuildInfo( GetBuildKey(build), GetBuildDefinitionInfo(build.ModelBuildDefinition), build.GitHubOrganization, build.GitHubRepository, build.PullRequestNumber, build.StartTime, build.FinishTime);
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}"); } }
public bool IsProcessed(ModelTimelineQuery timelineQuery, ModelBuild modelBuild) => Context.ModelTimelineQueryCompletes.Any(x => x.ModelTimelineQueryId == timelineQuery.Id && x.ModelBuildId == modelBuild.Id);
public static BuildKey GetBuildKey(ModelBuild build) => new BuildKey(build.ModelBuildDefinition.AzureOrganization, build.ModelBuildDefinition.AzureProject, build.BuildNumber);
public static GitHubPullRequestKey?GetGitHubPullRequestKey(ModelBuild build) => build.PullRequestNumber.HasValue ? (GitHubPullRequestKey?)new GitHubPullRequestKey(build.GitHubOrganization, build.GitHubRepository, build.PullRequestNumber.Value) : null;