diff --git a/src/dotnet/APIView/APIViewWeb/Controllers/AutoReviewController.cs b/src/dotnet/APIView/APIViewWeb/Controllers/AutoReviewController.cs index a53176e7e89..26dc1c50e1a 100644 --- a/src/dotnet/APIView/APIViewWeb/Controllers/AutoReviewController.cs +++ b/src/dotnet/APIView/APIViewWeb/Controllers/AutoReviewController.cs @@ -44,21 +44,23 @@ public async Task UploadAutoReview([FromForm] IFormFile file, stri } // Return internal server error for any unknown error return StatusCode(statusCode: StatusCodes.Status500InternalServerError); - } + } [HttpGet] - public async Task GetReviewStatus(string language, string packageName, string reviewId = null) + public async Task GetReviewStatus(string language, string packageName, string reviewId = null, bool? firstReleaseStatusOnly = null) { // This API is used by prepare release script to check if API review for a package is approved or not. // This caller script doesn't have artifact to submit and so it can't check using create review API // So it rely on approval status of latest revision of automatic review for the package // With new restriction of creating automatic review only from master branch or GA version, this should ensure latest revision - // is infact the version intended to be released. + // is infact the version intended to be released. + + ReviewType filtertype = (firstReleaseStatusOnly == true) ? ReviewType.All : ReviewType.Automatic; ReviewModel review; if (String.IsNullOrEmpty(reviewId)) { - IEnumerable reviews = await _reviewManager.GetReviewsAsync(false, language, packageName: packageName, ReviewType.Automatic); + IEnumerable reviews = await _reviewManager.GetReviewsAsync(false, language, packageName: packageName, filtertype); review = reviews.FirstOrDefault(); } else @@ -68,9 +70,10 @@ public async Task GetReviewStatus(string language, string packageN if (review != null) { - _logger.LogInformation("Found review ID " + review.ReviewId + " for package " + packageName); + _logger.LogInformation("Found review ID " + review.ReviewId + " for package " + packageName); + // Return 200 OK for approved review and 201 for review in pending status - if (review.Revisions.LastOrDefault().IsApproved) + if (firstReleaseStatusOnly != true && review.Revisions.LastOrDefault().IsApproved) { return Ok(); }