void ApplyBadgeUpdate(BadgeData Badge) { EventSummary Summary = FindOrAddSummary(Badge.ChangeNumber); BadgeData ExistingBadge = Summary.Badges.Find(x => x.ChangeNumber == Badge.ChangeNumber && x.BuildType == Badge.BuildType); if (ExistingBadge != null) { if (ExistingBadge.Id <= Badge.Id) { Summary.Badges.Remove(ExistingBadge); } else { return; } } Summary.Badges.Add(Badge); Summary.Verdict = GetVerdict(Summary.Reviews, Summary.Badges); BadgeData LatestBadge; if (!BadgeNameToLatestData.TryGetValue(Badge.BadgeName, out LatestBadge) || Badge.ChangeNumber > LatestBadge.ChangeNumber || (Badge.ChangeNumber == LatestBadge.ChangeNumber && Badge.Id > LatestBadge.Id)) { BadgeNameToLatestData[Badge.BadgeName] = Badge; } }
void ApplyBuildUpdate(BuildData Build) { EventSummary Summary = FindOrAddSummary(Build.ChangeNumber); BuildData ExistingBuild = Summary.Builds.Find(x => x.ChangeNumber == Build.ChangeNumber && x.BuildType == Build.BuildType); if (ExistingBuild != null) { if (ExistingBuild.Id <= Build.Id) { Summary.Builds.Remove(ExistingBuild); } else { return; } } Summary.Builds.Add(Build); Summary.Verdict = GetVerdict(Summary.Reviews, Summary.Builds); BuildData LatestBuild; if (!BadgeNameToLatestBuild.TryGetValue(Build.BadgeName, out LatestBuild) || Build.ChangeNumber > LatestBuild.ChangeNumber || (Build.ChangeNumber == LatestBuild.ChangeNumber && Build.Id > LatestBuild.Id)) { BadgeNameToLatestBuild[Build.BadgeName] = Build; } }
void ApplyEventUpdate(EventData Event) { EventSummary Summary = FindOrAddSummary(Event.Change); if (Event.Type == EventType.Starred || Event.Type == EventType.Unstarred) { // If it's a star or un-star review, process that separately if (Summary.LastStarReview == null || Event.Id > Summary.LastStarReview.Id) { Summary.LastStarReview = Event; } } else if (Event.Type == EventType.Investigating || Event.Type == EventType.Resolved) { // Insert it sorted in the investigation list int InsertIdx = 0; while (InsertIdx < InvestigationEvents.Count && InvestigationEvents[InsertIdx].Id < Event.Id) { InsertIdx++; } if (InsertIdx == InvestigationEvents.Count || InvestigationEvents[InsertIdx].Id != Event.Id) { InvestigationEvents.Insert(InsertIdx, Event); } ActiveInvestigations = null; } else if (Event.Type == EventType.Syncing) { Summary.SyncEvents.RemoveAll(x => String.Compare(x.UserName, Event.UserName, true) == 0); Summary.SyncEvents.Add(Event); ApplyFilteredUpdate(Event); } else if (IsReview(Event.Type)) { // Try to find an existing review by this user. If we already have a newer review, ignore this one. Otherwise remove it. EventData ExistingReview = Summary.Reviews.Find(x => String.Compare(x.UserName, Event.UserName, true) == 0); if (ExistingReview != null) { if (ExistingReview.Id <= Event.Id) { Summary.Reviews.Remove(ExistingReview); } else { return; } } // Add the new review, and find the new verdict for this change Summary.Reviews.Add(Event); Summary.Verdict = GetVerdict(Summary.Reviews, Summary.Builds); } else { // Unknown type } }
void ApplyCommentUpdate(CommentData Comment) { EventSummary Summary = FindOrAddSummary(Comment.ChangeNumber); if (String.Compare(Comment.UserName, CurrentUserName, true) == 0 && Summary.Comments.Count > 0 && Summary.Comments.Last().Id == long.MaxValue) { // This comment was added by PostComment(), to mask the latency of a round trip to the server. Remove it now we have the sorted comment. Summary.Comments.RemoveAt(Summary.Comments.Count - 1); } AddPerUserItem(Summary.Comments, Comment, x => x.Id, x => x.UserName); }
protected EventSummary FindOrAddSummary(int ChangeNumber) { EventSummary Summary; if (!ChangeNumberToSummary.TryGetValue(ChangeNumber, out Summary)) { Summary = new EventSummary(); Summary.ChangeNumber = ChangeNumber; ChangeNumberToSummary.Add(ChangeNumber, Summary); } return(Summary); }
public EventData GetReviewByCurrentUser(int ChangeNumber) { EventSummary Summary = GetSummaryForChange(ChangeNumber); if (Summary == null) { return(null); } EventData Event = Summary.Reviews.FirstOrDefault(x => String.Compare(x.UserName, CurrentUserName, true) == 0); if (Event == null || Event.Type == EventType.Unknown) { return(null); } return(Event); }
public bool GetCommentByCurrentUser(int ChangeNumber, out string CommentText) { EventSummary Summary = GetSummaryForChange(ChangeNumber); if (Summary == null) { CommentText = null; return(false); } CommentData Comment = Summary.Comments.Find(x => String.Compare(x.UserName, CurrentUserName, true) == 0); if (Comment == null || String.IsNullOrWhiteSpace(Comment.Text)) { CommentText = null; return(false); } CommentText = Comment.Text; return(true); }
void ApplyBuildUpdate(BuildData Build) { EventSummary Summary = FindOrAddSummary(Build.ChangeNumber); BuildData ExistingBuild = Summary.Builds.Find(x => x.ChangeNumber == Build.ChangeNumber && x.BuildType == Build.BuildType); if (ExistingBuild != null) { if (ExistingBuild.Id <= Build.Id) { Summary.Builds.Remove(ExistingBuild); } else { return; } } Summary.Builds.Add(Build); Summary.Verdict = GetVerdict(Summary.Reviews, Summary.Builds); }
public bool WasSyncedByCurrentUser(int ChangeNumber) { EventSummary Summary = GetSummaryForChange(ChangeNumber); return(Summary != null && Summary.SyncEvents.Any(x => x.Type == EventType.Syncing && String.Compare(x.UserName, CurrentUserName, true) == 0)); }