Example #1
0
        public async Task <IActionResult> ReviewGroupSubmit(int groupId)
        {
            var currentUser = await _userMan.GetUserAsync(_httpContext.HttpContext.User);

            _logger.LogInformation($"Review Submitted. GroupId = {groupId}");

            _logic.ReviewGroup(groupId, currentUser);

            // find review numbers
            var group = _context.Groups
                        .Include(g => g.Versions)
                        .ThenInclude(v => v.UserReviews)
                        .Where(g => g.GroupId == groupId).SingleOrDefault();
            var reviewedCount = group?.Versions.FirstOrDefault()?.UserReviews.Count() ?? 0;

            // load config for minimal review
            int    minimumReview           = 2; //Ĭ��ֵ2
            string minimumReviewFromConfig = _config.Get("ReviewThreshold");

            if (minimumReviewFromConfig != null)
            {
                int.TryParse(minimumReviewFromConfig, out minimumReview);
            }

            _logger.LogDebug($"Group {groupId} has {reviewedCount} reviews for last version.");
            if (reviewedCount >= minimumReview)
            {
                _logger.LogDebug($"Done Review: Group {groupId}");
                _taskDispatcher.DoneReview(new Group {
                    GroupId = groupId
                });
            }
            else
            {
                _logger.LogDebug($"Requeued to Review: Group {groupId}");
                _taskDispatcher.RequeueToReview(new Group {
                    GroupId = groupId
                });
            }


            return(RedirectToAction("ReviewGroup"));
        }