Exemplo n.º 1
0
 /// <summary>
 /// Получить общую информацию по метрикам.
 /// </summary>
 public MetricsBase GetBaseMetrics(int projectId)
 {
     using (this.unitOfWorkProvider.CreateUnitOfWork())
     {
         Project project = this.projectService.GetProject(projectId);
         IEnumerable <Project> projectList = this.projectService.GetProjects();
         var firstPostDate = this.statisticsProvider.GetFirstPostDate(projectId);
         return(new MetricsBase
         {
             Project = project,
             ProjectList = projectList,
             FirstPostDate = firstPostDate.HasValue ? this.dateTimeHelper.GetLocalUserDate(firstPostDate.Value) : (DateTime?)null
         });
     }
 }
Exemplo n.º 2
0
        public PostsMetrics GetPostsMetrics(int projectId)
        {
            using (this.unitOfWorkProvider.CreateUnitOfWork())
            {
                Project project = this.projectService.GetProject(projectId);
                IEnumerable <Project> projectList = this.projectService.GetProjects();
                var posts         = new List <PostEntityInfo>();
                var firstPostDate = this.statisticsProvider.GetFirstPostDate(projectId);

                return(new PostsMetrics
                {
                    Project = project,
                    ProjectList = projectList,
                    FirstPostDate = firstPostDate.HasValue ? this.dateTimeHelper.GetLocalUserDate(firstPostDate.Value) : (DateTime?)null,
                    MostPopularPosts = posts
                });
            }
        }
Exemplo n.º 3
0
        public CreateProjectResult CreateProject(Project project)
        {
            using (ICommandSender commandSender = Factory.GetInstance <ICommandSender>().Open(CONST_CreateProjectQueueName))
            {
                string ticketId  = Guid.NewGuid().ToString();
                int    accountId = this.currentUserProvider.GetAccountOfCurrentUser().Id;

                CreateProjectCommand command = new CreateProjectCommand
                {
                    AccountId = accountId,
                    Title     = project.Title,
                    Url       = project.Url,
                    TicketId  = ticketId
                };

                commandSender.SendCommand(command);
                return(new CreateProjectResult {
                    TicketId = ticketId
                });
            }
        }
Exemplo n.º 4
0
        public SocialMetrics GetSocialMetrics(int projectId)
        {
            using (this.unitOfWorkProvider.CreateUnitOfWork())
            {
                Project project = this.projectService.GetProject(projectId);
                IEnumerable <Project> projectList = this.projectService.GetProjects();
                var firstPostDate = this.statisticsProvider.GetFirstPostDate(projectId);
                IEnumerable <LocationInfoGroupedObject> mostPopularCities = this.statisticsProvider.GetMostPopularCities(projectId);
                int membersWithoutCity = this.statisticsProvider.GetMembersWithoutCityCount(projectId);

                return(new SocialMetrics
                {
                    Project = project,
                    ProjectList = projectList,
                    FirstPostDate = firstPostDate.HasValue ? this.dateTimeHelper.GetLocalUserDate(firstPostDate.Value) : (DateTime?)null,
                    MostPopularCities = mostPopularCities.Select(c => new PopularCityInfo {
                        City = c.City, MembersCount = c.Count, Country = c.Country
                    }).ToList(),
                    MembersWithoutCity = membersWithoutCity
                });
            }
        }
Exemplo n.º 5
0
        public DashboardMetrics GetDashboardMetrics(int projectId, DateRange dateRange)
        {
            dateRange.To = dateRange.To.AddDays(1);
            using (this.unitOfWorkProvider.CreateUnitOfWork())
            {
                Project project = this.projectService.GetProject(projectId);
                IEnumerable <Project> projectList = this.projectService.GetProjects();

                var postMostCrowdedTime = this.analyticsService.GetPostMostCrowdedTime(projectId, dateRange);
                var userStatistics      = this.analyticsService.GetInactiveUsersCount(projectId, dateRange);

                Kpi kpi = this.kpiProvider.GetKpis(projectId, dateRange);

                var averageLikesPerPost    = kpi.AverageLikesPerPost;
                var interactionRate        = kpi.InteractionRate;
                var responseRate           = kpi.ResponseRate;
                var responseTime           = this.GetResponseTime(projectId, dateRange);
                var involmentRate          = kpi.InvolmentRate;
                var ugcRate                = kpi.UgcRate;
                var postsCount             = kpi.PostsCount;
                var averageCommentsPerPost = kpi.AverageCommentsPerPost;
                var usersPostCount         = kpi.UserPostsCount;
                var adminPostCount         = kpi.AdminPostsCount;
                var usersPostsPerUser      = kpi.UserPostsPerUser;
                var adminPostsPerAdmin     = kpi.AdminPostsPerAdmin;
                var usersCount             = kpi.UsersCount;

                var photosCount        = this.statisticsProvider.GetPhotosCount(projectId, dateRange);
                var videosCount        = this.statisticsProvider.GetVideosCount(projectId, dateRange);
                var topicsCount        = this.statisticsProvider.GetTopicsCount(projectId, dateRange);
                var topicCommentsCount = this.statisticsProvider.GetTopicCommentsCount(projectId, dateRange);
                var firstPostDate      = this.statisticsProvider.GetFirstPostDate(projectId);
                var lastPostDate       = this.statisticsProvider.GetLastPostDate(projectId);

                return(new DashboardMetrics
                {
                    Project = project,
                    ProjectList = projectList,
                    AverageLikesPerPost = Math.Round(averageLikesPerPost, 2),
                    AverageCommentsPerPost = Math.Round(averageCommentsPerPost, 2),
                    InteractionRate = Math.Round(interactionRate, 2),
                    ResponseRate = Math.Round(responseRate, 2),
                    ResponseTime = responseTime,
                    InvolmentRate = Math.Round(involmentRate, 2),
                    UsersCount = usersCount,
                    UsersPostCount = usersPostCount,
                    AdminPostCount = adminPostCount,
                    UsersPostsPerUser = Math.Round(usersPostsPerUser, 2),
                    AdminPostsPerAdmin = Math.Round(adminPostsPerAdmin, 2),
                    UgcRate = Math.Round(ugcRate, 2),
                    PhotosCount = photosCount,
                    VideosCount = videosCount,
                    TopicsCount = topicsCount,
                    TopicCommentsCount = topicCommentsCount,
                    PostsCount = postsCount,
                    FirstPostDate = firstPostDate.HasValue ? this.dateTimeHelper.GetLocalUserDate(firstPostDate.Value) : (DateTime?)null,
                    LastPostDate = lastPostDate.HasValue ? this.dateTimeHelper.GetLocalUserDate(lastPostDate.Value) : (DateTime?)null,
                    PostBiggestActivities = postMostCrowdedTime,
                    InactiveUsersCount = userStatistics.InactiveUsers.Count,
                    BadFans = userStatistics.BlockedUsers.Count + userStatistics.DeletedUsers.Count,
                    BotsCount = userStatistics.Bots.Count,
                    ActiveUsersCount = userStatistics.ActiveUsers.Count,
                    AllUserIds = userStatistics.AllUsers,
                    SharePerPost = Math.Round(kpi.SharePerPosts, 2)
                });
            }
        }