public IEnumerable <ServerReportInfo> GetPopularServers(int count)
        {
            if (count < 0 || count > Constants.MaxCount)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            var servers = database.GetServers();
            var last    = database.GetLastMatchDateTime();

            return(database.GetMatches()
                   .GroupBy(x => x.endpoint)
                   .Select(g =>
            {
                var endpoint = g.Key;

                var first = g.Min(x => x.timestamp);
                var totalDays = (last - first).Days + 1;
                var averageMatchParDay = (double)g.Count() / totalDays;

                var name = servers.First(x => x.endpoint.Equals(endpoint)).info.name;

                return new ServerReportInfo
                {
                    endpoint = endpoint,
                    name = name,
                    averageMatchesPerDay = averageMatchParDay
                };
            })
                   .OrderByDescending(x => x.averageMatchesPerDay)
                   .Take(count));
        }
Пример #2
0
        public Dictionary <string, dynamic> GetStatistic(string endpoint)
        {
            var matches       = database.GetMatches(endpoint).ToArray();
            var lastMatchData = database.GetLastMatchDateTime();

            var statistic = new Dictionary <string, dynamic>
            {
                { "totalMatchesPlayed", GetTotalMatchesPlayed(matches) },
                { "maximumMatchesPerDay", GetMaximumMatchesPerDay(matches) },
                { "averageMatchesPerDay", GetAverageMatchesPerDay(matches, lastMatchData) },
                { "maximumPopulation", GetMaximumPopulation(matches) },
                { "averagePopulation", GetAveragePopulation(matches) },
                { "top5GameModes", GetTop5GameModes(matches) },
                { "top5Maps", GetTop5Maps(matches) }
            };

            return(statistic);
        }
Пример #3
0
        public Dictionary <string, dynamic> GetStatistic(string playerName)
        {
            var matches       = database.GetMatchesWithPlayer(playerName);
            var lastMatchData = database.GetLastMatchDateTime();

            var statistic = new Dictionary <string, dynamic>
            {
                { "totalMatchesPlayed", GetTotalMatchesPlayed(matches) },
                { "totalMatchesWon", GetTotalMatchesWon(matches, playerName) },
                { "favoriteServer", GetFavoriteServer(matches) },
                { "uniqueServers", GetUniqueServersCount(matches) },
                { "favoriteGameMode", GetFavoriteGameMode(matches) },
                { "averageScoreboardPercent", GetAverageScoreboardPercent(matches, playerName) },
                { "maximumMatchesPerDay", GetMaximumMatchesPerDay(matches) },
                { "averageMatchesPerDay", GetAverageMatchesPerDay(matches, lastMatchData) },
                { "lastMatchPlayed", GetLastMatchDateTime(matches).ToUtcString() },
                { "killToDeathRatio", GetKillToDeathRatio(matches, playerName) }
            };

            return(statistic);
        }