private async Task UpdateReviewAsync(ReviewModel review)
        {
            foreach (var revision in review.Revisions)
            {
                foreach (var file in revision.Files)
                {
                    if (!file.HasOriginal)
                    {
                        continue;
                    }

                    var fileOriginal = await _originalsRepository.GetOriginalAsync(file.ReviewFileId);

                    var languageService = GetLanguageService(file.Language);

                    // file.Name property has been repurposed to store package name and version string
                    // This is causing issue when updating review using latest parser since it expects Name field as file name
                    // We have added a new property FileName which is only set for new reviews
                    // All older reviews needs to be handled by checking Name field
                    // If name field has no extension and File Name is Emtpy then use review.Name
                    var fileName = file.FileName ?? (Path.HasExtension(file.Name)? file.Name : review.Name);
                    var codeFile = await languageService.GetCodeFileAsync(fileName, fileOriginal, review.RunAnalysis);

                    await _codeFileRepository.UpsertCodeFileAsync(revision.RevisionId, file.ReviewFileId, codeFile);

                    InitializeFromCodeFile(file, codeFile);
                    file.FileName = fileName;
                }
            }

            await _reviewsRepository.UpsertReviewAsync(review);
        }
        internal async Task UpdateReviewAsync(ClaimsPrincipal user, string id)
        {
            var review = await GetReviewAsync(user, id);

            foreach (var revision in review.Revisions)
            {
                foreach (var file in revision.Files)
                {
                    if (!file.HasOriginal)
                    {
                        continue;
                    }

                    var fileOriginal = await _originalsRepository.GetOriginalAsync(file.ReviewFileId);

                    var languageService = GetLanguageService(file.Language);

                    var codeFile = await languageService.GetCodeFileAsync(file.Name, fileOriginal, review.RunAnalysis);

                    await _codeFileRepository.UpsertCodeFileAsync(revision.RevisionId, file.ReviewFileId, codeFile);

                    InitializeFromCodeFile(file, codeFile);
                }
            }

            await _reviewsRepository.UpsertReviewAsync(review);
        }
Beispiel #3
0
        private async Task UpdateReviewAsync(ReviewModel review)
        {
            foreach (var revision in review.Revisions.Reverse())
            {
                foreach (var file in revision.Files)
                {
                    if (!file.HasOriginal)
                    {
                        continue;
                    }

                    try
                    {
                        var fileOriginal = await _originalsRepository.GetOriginalAsync(file.ReviewFileId);

                        var languageService = GetLanguageService(file.Language);

                        // file.Name property has been repurposed to store package name and version string
                        // This is causing issue when updating review using latest parser since it expects Name field as file name
                        // We have added a new property FileName which is only set for new reviews
                        // All older reviews needs to be handled by checking review name field
                        var fileName = file.FileName ?? (Path.HasExtension(review.Name) ? review.Name : file.Name);
                        var codeFile = await languageService.GetCodeFileAsync(fileName, fileOriginal, review.RunAnalysis);

                        await _codeFileRepository.UpsertCodeFileAsync(revision.RevisionId, file.ReviewFileId, codeFile);

                        // update only version string
                        file.VersionString = codeFile.VersionString;
                    }
                    catch (Exception ex) {
                        _telemetryClient.TrackTrace("Failed to update review " + review.ReviewId);
                        _telemetryClient.TrackException(ex);
                    }
                }
            }

            await _reviewsRepository.UpsertReviewAsync(review);
        }