Esempio n. 1
0
        public static List <Place> DeterminePlaces(
            this List <UserStats> _stats,
            UserStatSortColumn _sortBy)
        {
            List <UserStats> sorted = _stats.OrderByDescending(u => u.SortColumnValue(_sortBy)).ToList();
            List <Place>     places = new List <Place>();

            Place currentPlace = new Place();

            currentPlace.Score = 0;

            //get the user stats based on hydrants
            foreach (var userStat in sorted)
            {
                var score = userStat.SortColumnValue(_sortBy);
                if (score == currentPlace.Score)
                {
                    currentPlace.UsersAtThisPosition.Add(userStat);
                }
                else
                {
                    if (score > 0)
                    {
                        currentPlace       = new Place();
                        currentPlace.Score = userStat.SortColumnValue(_sortBy);
                        currentPlace.UsersAtThisPosition.Add(userStat);
                        currentPlace.SortedBy = _sortBy;
                        places.Add(currentPlace);
                    }
                }
            }

            return(places);
        }
Esempio n. 2
0
        public static int SortColumnValue(this UserStats _stat, UserStatSortColumn _sortBy)
        {
            if (_sortBy == UserStatSortColumn.NewHydrant)
            {
                return(_stat.NewHydrantsTagged);
            }

            if (_sortBy == UserStatSortColumn.ApprovedTags)
            {
                return(_stat.ApprovedTagCount);
            }

            if (_sortBy == UserStatSortColumn.RejectedTags)
            {
                return(_stat.RejectedTagCount);
            }

            if (_sortBy == UserStatSortColumn.PendingTags)
            {
                return(_stat.PendingTagCount);
            }

            throw new Exception("Unknown sortby column");
        }