コード例 #1
0
        public async Task <StatsDTO> CreateStats()
        {
            var now = _currentTimeProvider.Now;

            using (var uow = UnitOfWorkProvider.Create())
            {
                var result = new StatsDTO
                {
                    RunCountLastHour =
                        await uow.Context.Runs.CountAsync(r => r.CreatedAt > now.AddHours(-1)),

                    RunCountLastDay =
                        await uow.Context.Runs.CountAsync(r => r.CreatedAt > now.AddDays(-1)),

                    UploadedFilesCountThisWeek =
                        await uow.Context.Files.CountAsync(f => f.CreatedAt > now.AddDays(-7)),

                    UploadedFilesSizeThisWeek =
                        await uow.Context.Files.Where(f => f.CreatedAt > now.AddDays(-7)).SumAsync(f => f.FileSize),

                    ActiveUserCountLastDay =
                        await uow.Context.Users.CountAsync(u => u.Runs.Any(r => r.CreatedAt > now.AddDays(-1))),

                    RegisterUserCountThisWeek =
                        await uow.Context.Users.CountAsync(u => u.CreatedAt > now.AddDays(-7)),

                    BrokerStatus = _brokerStatus.GetStatus(),

                    BrokerClients = await _brokerStatus.GetConnectedAlgServersCount()
                };

                return(result);
            }
        }
コード例 #2
0
        public ActionResult <StatsDTO> GetById(int id)
        {
            StatsDTO s = _statsService.GetByID(id);

            if (s == null)
            {
                return(NotFound());
            }

            return(s);
        }
コード例 #3
0
        public IActionResult PostUrl(UrlInputDTO urlInputDTO, int userid)
        {
            StatsDTO s = _usersService.CreateUrl(urlInputDTO, userid);

            if (s == null)
            {
                return(BadRequest());
            }

            return(Created("api/stats/" + s.ID.ToString(), s));
        }
コード例 #4
0
        /// <summary>
        /// Get Stats for Sidebar Widget
        /// </summary>
        /// <returns>DTO object with the Stats</returns>
        public StatsDTO RetrieveSidebarStats(bool ispremium)
        {
            StatsDTO model = new StatsDTO();

            if (ispremium)
            {
                model.TopRatedPosts      = PostRepository.Get(p => p.Ratings.Any() && p.IsAboutMe == false, o => o.OrderByDescending(p => p.Ratings.Average(r => r.Value)), "Ratings").Take(10);
                model.MostVisitedPosts   = PostRepository.Get(p => p.Visits > 0 && p.IsAboutMe == false, o => o.OrderByDescending(p => p.Visits)).Take(10);
                model.MostCommentedPosts = PostRepository.Get(p => p.Comments.Any() && p.IsAboutMe == false, o => o.OrderByDescending(c => c.Comments.Count()), "Comments").Take(10);
            }
            else
            {
                model.TopRatedPosts      = PostRepository.Get(p => p.Ratings.Any() && p.IsPublic && p.IsAboutMe == false, o => o.OrderByDescending(p => p.Ratings.Average(r => r.Value)), "Ratings,Image").Take(10);
                model.MostVisitedPosts   = PostRepository.Get(p => p.Visits > 0 && p.IsPublic && p.IsAboutMe == false, o => o.OrderByDescending(p => p.Visits), "Image").Take(10);
                model.MostCommentedPosts = PostRepository.Get(p => p.Comments.Any() && p.IsPublic && p.IsAboutMe == false, o => o.OrderByDescending(c => c.Comments.Count()), "Comments,Image").Take(10);
            }
            return(model);
        }
コード例 #5
0
        /// <summary>
        /// Get Stats from all entities in Model
        /// </summary>
        /// <returns>DTO object with the Stats</returns>
        public StatsDTO RetrieveBlogStats()
        {
            StatsDTO model = new StatsDTO();

            model.TotalPosts         = PostRepository.GetCount();
            model.TotalTags          = TagRepository.GetCount();
            model.TotalAlbums        = AlbumRepository.GetCount();
            model.TotalCategories    = CategoryRepository.GetCount();
            model.TotalImages        = ImageRepository.GetCount();
            model.TotalUsers         = UserRepository.GetCount();
            model.TotalComments      = CommentRepository.GetCount();
            model.TotalRoles         = RoleRepository.GetCount();
            model.TopRatedPosts      = PostRepository.Get(p => p.Ratings.Any(), o => o.OrderByDescending(p => p.Ratings.Average(r => r.Value)), "Ratings").Take(10);
            model.MostVisitedPosts   = PostRepository.Get(p => p.Visits > 0, o => o.OrderByDescending(p => p.Visits)).Take(10);
            model.MostCommentedPosts = PostRepository.Get(p => p.Comments.Any(), o => o.OrderByDescending(c => c.Comments.Count()), "Comments").Take(10);
            model.PostWritenByUser   = UserRepository.Get(u => u.Roles.Any(r => r.RoleName == "admin"));
            return(model);
        }
コード例 #6
0
ファイル: Mapper.cs プロジェクト: Tramwaj/BBTrackerWebApp
        internal static StatsDTO DTOFromStats(Stats stats)
        {
            var dto = new StatsDTO();

            dto.PlayerId           = stats.Id;
            dto.Points             = stats.Points;
            dto.FieldGoalsMade2p   = stats.FieldGoalsMade2p;
            dto.FieldGoalsMissed2p = stats.FieldGoalsMissed2p;
            dto.FieldGoalsMade3p   = stats.FieldGoalsMade3p;
            dto.FieldGoalsMissed3p = stats.FieldGoalsMissed3p;
            dto.Assists            = stats.Assists;
            dto.Rebounds           = stats.TotalRebounds;
            dto.DefensiveRebounds  = stats.DefensiveRebounds;
            dto.OffensiveRebounds  = stats.OffensiveRebounds;
            dto.Steals             = stats.Steals;
            dto.Blocks             = stats.Blocks;
            dto.Turnovers          = stats.Turnovers;
            return(dto);
        }
コード例 #7
0
        public async Task <DataDTO> GetCurrentStats(string miner)
        {
            DataDTO  data         = null;
            StatsDTO currentStats = null;

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync($"/miner/:{miner}/currentStats");

                //Checking the response is successful or not which is sent using HttpClient
                var settings = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var    Response = Res.Content.ReadAsStringAsync().Result;
                    string info     = Response;
                    var    data2    = JsonConvert.DeserializeObject <StatsDTO>(info, settings);
                    currentStats = data2;
                }
                if (currentStats.Status.ToLower() == "error")
                {
                    throw new BusinessLogicException(currentStats.Error, "");
                }

                data = currentStats.Data;
            }
            return(data);
        }