Skip to content

Commit

Permalink
fix images service being required even if feature is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DmyMi committed Apr 20, 2023
1 parent 1053db9 commit 62e7711
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ public static IServiceCollection AddImagesStorage(this IServiceCollection servic
{
_ = services ?? throw new ArgumentNullException(nameof(services));

var isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development;

if (turnOnFakeStorage && isDevelopment)
if (turnOnFakeStorage)
{
return services.AddTransient<IImageFilesStorage, FakeImagesStorage>();
}
Expand Down
7 changes: 5 additions & 2 deletions OutOfSchool/OutOfSchool.WebApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ public static void AddApplicationServices(this WebApplicationBuilder builder)
services.AddTransient<IProviderRepository, ProviderRepository>();
services.AddTransient<IWorkshopRepository, WorkshopRepository>();
//services.AddTransient<IExternalImageStorage, ExternalImageStorage>();
services.AddImagesStorage(turnOnFakeStorage: configuration.GetValue<bool>("TurnOnFakeImagesStorage"));
var featuresConfig = configuration.GetSection(FeatureManagementConfig.Name).Get<FeatureManagementConfig>();
var isImagesEnabled = featuresConfig.Images;
var turnOnFakeStorage = configuration.GetValue<bool>("Images:TurnOnFakeImagesStorage") || !isImagesEnabled;
services.AddImagesStorage(turnOnFakeStorage: turnOnFakeStorage);

services.AddTransient<IElasticsearchSyncRecordRepository, ElasticsearchSyncRecordRepository>();
services.AddTransient<INotificationRepository, NotificationRepository>();
Expand Down Expand Up @@ -332,7 +335,7 @@ public static void AddApplicationServices(this WebApplicationBuilder builder)
quartzConfig.ConnectionStringKey,
q =>
{
if (!builder.Environment.IsEnvironment("Release"))
if (!turnOnFakeStorage)
{
// TODO: for now this is not used in release
q.AddGcpSynchronization(services, quartzConfig);
Expand Down
4 changes: 3 additions & 1 deletion OutOfSchool/OutOfSchool.WebApi/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
"Quartz": {
"ConnectionStringKey": "QuartzConnection"
},
"TurnOnFakeImagesStorage": true,
"Redis": {
"Password": "Qwerty123!"
},
"Images": {
"TurnOnFakeImagesStorage": true
}
}
5 changes: 4 additions & 1 deletion OutOfSchool/OutOfSchool.WebApi/appsettings.Release.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

"FeatureManagement": {
"Release1": true,
"Release2": true,
"Release2": false,
"Release3": false,
"Images": false
},
Expand Down Expand Up @@ -144,6 +144,9 @@
},
"StatisticReports": {
"UseExternalStorage": false
},
"Images": {
"TurnOnFakeImagesStorage": true
}
}

Expand Down
131 changes: 66 additions & 65 deletions OutOfSchool/OutOfSchool.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,60 +80,61 @@
}
},
"Images": {
"Workshop": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 1,
"MaxWidthHeightRatio": 3,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Limits": {
"MaxCountOfFiles": 10
}
"TurnOnFakeImagesStorage": false,
"Workshop": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 1,
"MaxWidthHeightRatio": 3,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Teacher": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 0.5,
"MaxWidthHeightRatio": 2,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Limits": {
"MaxCountOfFiles": 1
}
"Limits": {
"MaxCountOfFiles": 10
}
},
"Teacher": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 0.5,
"MaxWidthHeightRatio": 2,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Provider": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 0.5,
"MaxWidthHeightRatio": 2,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Limits": {
"MaxCountOfFiles": 4
}
"Limits": {
"MaxCountOfFiles": 1
}
},
"Provider": {
"Specs": {
"MinWidthPixels": 350,
"MaxWidthPixels": 10000,
"MinHeightPixels": 250,
"MaxHeightPixels": 8000,
"MaxSizeBytes": 16777216,
"MinWidthHeightRatio": 0.5,
"MaxWidthHeightRatio": 2,
"SupportedFormats": [
"jpeg",
"png"
]
},
"Limits": {
"MaxCountOfFiles": 4
}
}
},

"AllowedHosts": "*",
Expand Down Expand Up @@ -213,21 +214,21 @@
}
},

"ChangesLog": {
"TrackedProperties": {
"Provider": [ "FullTitle", "EdrpouIpn", "Director", "LegalAddress", "InstitutionId" ],
"Application": [ "Status" ]
}
},
"GeoCoding": {
"BaseUrl": "https://api.visicom.ua/data-api/5.0/uk/geocode.json",
"ApiKey": "",
"Radius": 50
},

"StatisticReports": {
"UseExternalStorage": false
"ChangesLog": {
"TrackedProperties": {
"Provider": [ "FullTitle", "EdrpouIpn", "Director", "LegalAddress", "InstitutionId" ],
"Application": [ "Status" ]
}
},
"GeoCoding": {
"BaseUrl": "https://api.visicom.ua/data-api/5.0/uk/geocode.json",
"ApiKey": "",
"Radius": 50
},

"StatisticReports": {
"UseExternalStorage": false
}
}


0 comments on commit 62e7711

Please sign in to comment.