Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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));
        }