Example #1
0
        public ActionResult GetData(int id, DataFilter filter)
        {
            var builder = new ActiveUserJsonModelBuilder(this.metricsService, this.searchService);
            ActiveUserJsonModel json = builder.GetActiveUserModel(id, filter, ActiveUserJsonModelBuilderOptions.Default);

            return(this.Chart(json));
        }
        public ActiveUserJsonModel GetActiveUserModel(int id, DataFilter filter, ActiveUserJsonModelBuilderOptions options)
        {
            var result = new ActiveUserJsonModel();

            if (filter.Period == FilteringPeriod.Other && filter.DateRange.From > filter.DateRange.To)
            {
                return(result);
            }

            var activeUsers  = this.metricsService.GetUserMetrics(id, DateRangeConverter.GetDateRange(filter), options.UserTableCount);
            var usersList    = activeUsers.MostActiveUsers.Take(options.ReportCount).ToList();
            var usersListIds = usersList.Select(u => u.Id).ToArray();
            var users        = new ActiveUserViewModel(activeUsers);

            if (users.MostActiveUsers.Count != 0)
            {
                result.Table              = this.GetTable(users.MostActiveUsers.ToList());
                result.InterestsData      = this.GetInterests(id, usersListIds, options.InterestCount);
                result.AgeData            = this.GetAgeInfo(id, usersList);
                result.GenderData         = this.GetGenderInfo(id, usersList);
                result.EducationData      = this.GetEducationInfo(id, usersList);
                result.CountryAndCityData = this.GetCountryAndCityInfo(id, usersListIds);
            }

            result.Table = this.GetTable(users.MostActiveUsers.ToList());
            return(result);
        }