Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APIView] Disable auto upgrade of APIView review #9820

Merged
merged 7 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using APIViewWeb.Managers.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using APIViewWeb.Hubs;
using System.Collections.Generic;
using APIViewWeb.Managers;
Expand Down Expand Up @@ -32,13 +33,15 @@ public APIRevisionsManagerTests()
IBlobOriginalsRepository blobOriginalRepository = new Mock<IBlobOriginalsRepository>().Object;
INotificationManager notificationManager = new Mock<INotificationManager>().Object;
TelemetryClient telemetryClient = new Mock<TelemetryClient>().Object;
IConfiguration configuration = new ConfigurationBuilder().Build();

_apiRevisionsManager = new APIRevisionsManager(
authorizationService: authorizationService, reviewsRepository: cosmosReviewRepository,
apiRevisionsRepository: cosmosAPIRevisionsRepository, signalRHubContext: signalRHub,
languageServices: languageServices, devopsArtifactRepository: devopsArtifactRepository,
codeFileManager: codeFileManager, codeFileRepository: blobCodeFileRepository,
originalsRepository: blobOriginalRepository, notificationManager: notificationManager, telemetryClient: telemetryClient);
originalsRepository: blobOriginalRepository, notificationManager: notificationManager, telemetryClient: telemetryClient,
configuration: configuration);
}

// GetLatestAPIRevisionsAsync
Expand Down
14 changes: 13 additions & 1 deletion src/dotnet/APIView/APIViewWeb/Managers/APIRevisionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -36,6 +37,7 @@ public class APIRevisionsManager : IAPIRevisionsManager
private readonly IBlobOriginalsRepository _originalsRepository;
private readonly INotificationManager _notificationManager;
private readonly TelemetryClient _telemetryClient;
private readonly HashSet<string> _upgradeDisabledLangs = new HashSet<string>();

public APIRevisionsManager(
IAuthorizationService authorizationService,
Expand All @@ -48,7 +50,8 @@ public APIRevisionsManager(
IBlobCodeFileRepository codeFileRepository,
IBlobOriginalsRepository originalsRepository,
INotificationManager notificationManager,
TelemetryClient telemetryClient)
TelemetryClient telemetryClient,
IConfiguration configuration)
{
_reviewsRepository = reviewsRepository;
_apiRevisionsRepository = apiRevisionsRepository;
Expand All @@ -61,6 +64,11 @@ public APIRevisionsManager(
_originalsRepository = originalsRepository;
_notificationManager = notificationManager;
_telemetryClient = telemetryClient;
var backgroundTaskDisabledLangs = configuration["ReviewUpdateDisabledLanguages"];
if(!string.IsNullOrEmpty(backgroundTaskDisabledLangs))
{
_upgradeDisabledLangs.UnionWith(backgroundTaskDisabledLangs.Split(','));
}
}

/// <summary>
Expand Down Expand Up @@ -1006,6 +1014,10 @@ private async Task<APIRevisionListItemModel> UpgradeAPIRevisionIfRequired(APIRev
return revisionModel;
}
var codeFileDetails = revisionModel.Files[0];
if (_upgradeDisabledLangs.Contains(codeFileDetails.Language))
{
return revisionModel;
}
var languageService = LanguageServiceHelpers.GetLanguageService(codeFileDetails.Language, _languageServices);
if (languageService != null && languageService.CanUpdate(codeFileDetails.VersionString))
{
Expand Down