Skip to content

Commit

Permalink
Add API to get status of package name approval (#5570)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu authored Feb 28, 2023
1 parent 848799e commit 8f65722
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,23 @@ public async Task<ActionResult> UploadAutoReview([FromForm] IFormFile file, stri
}
// Return internal server error for any unknown error
return StatusCode(statusCode: StatusCodes.Status500InternalServerError);
}
}

[HttpGet]
public async Task<ActionResult> GetReviewStatus(string language, string packageName, string reviewId = null)
public async Task<ActionResult> 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<ReviewModel> reviews = await _reviewManager.GetReviewsAsync(false, language, packageName: packageName, ReviewType.Automatic);
IEnumerable<ReviewModel> reviews = await _reviewManager.GetReviewsAsync(false, language, packageName: packageName, filtertype);
review = reviews.FirstOrDefault();
}
else
Expand All @@ -68,9 +70,10 @@ public async Task<ActionResult> 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();
}
Expand Down

0 comments on commit 8f65722

Please sign in to comment.