示例#1
0
        protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request)
        {
            var heapingAlgorithm = await HeapingAlgorithm.OfDeckAsync(DbContext, request.DeckId);

            var userNames  = DbContext.Users.AsNoTracking().Select(u => new { u.Id, u.UserName }).ToImmutableDictionary(u => u.Id, u => u.UserName);
            var imageNames = ImageLoadingHelper.GetAllImageNames(DbContext);
            var tagNames   = TagLoadingHelper.Run(DbContext);

            var result = await RunAsync(request, heapingAlgorithm, userNames, imageNames, tagNames, now == null?DateTime.UtcNow : now.Value);

            return(new ResultWithMetrologyProperties <Result>(new Result(result),
                                                              ("DeckId", request.DeckId.ToString()),
                                                              ("ExcludedCardCount", request.ExcludedCardIds.Count().ToString()),
                                                              ("ExcludedTagCount", request.ExcludedTagIds.Count().ToString()),
                                                              ("RequestedCardCount", request.CardsToDownload.ToString()),
                                                              ("ResultCount", result.Count.ToString())));
        }
示例#2
0
        protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request)
        {
            var heapingAlgorithm = await HeapingAlgorithm.OfDeckAsync(DbContext, request.DeckId);

            var userNames  = DbContext.Users.AsNoTracking().Select(u => new { u.Id, u.UserName }).ToImmutableDictionary(u => u.Id, u => u.UserName);
            var imageNames = ImageLoadingHelper.GetAllImageNames(DbContext);
            var tagNames   = TagLoadingHelper.Run(DbContext);

            var result = new List <ResultCard>();

            result.AddRange(await GetUnknownCardsAsync(request.CurrentUserId, request.DeckId, request.ExcludedCardIds, request.ExcludedTagIds, heapingAlgorithm, userNames, imageNames, tagNames, request.CardsToDownload, true));
            result.AddRange(await GetUnknownCardsAsync(request.CurrentUserId, request.DeckId, request.ExcludedCardIds, request.ExcludedTagIds, heapingAlgorithm, userNames, imageNames, tagNames, request.CardsToDownload - result.Count, false));

            return(new ResultWithMetrologyProperties <Result>(new Result(result),
                                                              ("DeckId", request.DeckId.ToString()),
                                                              ("ExcludedCardCount", request.ExcludedCardIds.Count().ToString()),
                                                              ("ExcludedTagCount", request.ExcludedTagIds.Count().ToString()),
                                                              ("RequestedCardCount", request.CardsToDownload.ToString()),
                                                              ("ResultCount", result.Count.ToString())));
        }