diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8821eef..718874b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -37,7 +37,8 @@ "Zignd.html-css-class-completion", "PWABuilder.pwa-studio", "ms-azuretools.vscode-docker", - "SonarSource.sonarlint-vscode" + "SonarSource.sonarlint-vscode", + "oderwat.indent-rainbow" ] } } diff --git a/gaseous-server/Classes/Filters.cs b/gaseous-server/Classes/Filters.cs index 69697b5..ace250c 100644 --- a/gaseous-server/Classes/Filters.cs +++ b/gaseous-server/Classes/Filters.cs @@ -24,8 +24,7 @@ namespace gaseous_server.Classes ageRestriction_Generic += " OR view_Games.AgeGroupId IS NULL"; } - string sql = "SELECT Platform.Id, Platform.`Name`, COUNT(Game.Id) AS GameCount FROM (SELECT DISTINCT Game.Id, view_Games_Roms.PlatformId, COUNT(view_Games_Roms.Id) AS RomCount FROM Game LEFT JOIN AgeGroup ON Game.Id = AgeGroup.GameId LEFT JOIN view_Games_Roms ON Game.Id = view_Games_Roms.GameId WHERE (" + ageRestriction_Platform + ") GROUP BY Game.Id , view_Games_Roms.PlatformId HAVING RomCount > 0) Game JOIN Platform ON Game.PlatformId = Platform.Id GROUP BY Platform.`Name`;"; - Console.WriteLine(sql); + string sql = "SELECT Platform.Id, Platform.`Name`, COUNT(Game.Id) AS GameCount FROM (SELECT DISTINCT Game.Id, view_Games_Roms.PlatformId, COUNT(view_Games_Roms.Id) AS RomCount FROM Game LEFT JOIN AgeGroup ON Game.Id = AgeGroup.GameId LEFT JOIN view_Games_Roms ON Game.Id = view_Games_Roms.GameId WHERE (" + ageRestriction_Platform + ") GROUP BY Game.Id , view_Games_Roms.PlatformId HAVING RomCount > 0) Game JOIN Platform ON Game.PlatformId = Platform.Id AND Platform.SourceId = 0 GROUP BY Platform.`Name`;"; DataTable dbResponse = db.ExecuteCMD(sql, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 300)); diff --git a/gaseous-server/Classes/Metadata/Communications.cs b/gaseous-server/Classes/Metadata/Communications.cs index 6019962..e979040 100644 --- a/gaseous-server/Classes/Metadata/Communications.cs +++ b/gaseous-server/Classes/Metadata/Communications.cs @@ -1108,21 +1108,21 @@ namespace gaseous_server.Classes.Metadata return false; } - public async Task GetSpecificImageFromServer(string ImagePath, string ImageId, IGDBAPI_ImageSize size, List? FallbackSizes = null) + public async Task GetSpecificImageFromServer(HasheousClient.Models.MetadataSources SourceType, string ImagePath, string ImageId, IGDBAPI_ImageSize size, List? FallbackSizes = null) { - string originalPath = Path.Combine(ImagePath, _MetadataSource.ToString(), IGDBAPI_ImageSize.original.ToString()); + string originalPath = Path.Combine(ImagePath, SourceType.ToString(), IGDBAPI_ImageSize.original.ToString()); string originalFilePath = Path.Combine(originalPath, ImageId); - string requestedPath = Path.Combine(ImagePath, _MetadataSource.ToString(), size.ToString()); + string requestedPath = Path.Combine(ImagePath, SourceType.ToString(), size.ToString()); string requestedFilePath = Path.Combine(requestedPath, ImageId); // create the directory if it doesn't exist - if (!Directory.Exists(Path.GetDirectoryName(originalPath))) + if (!Directory.Exists(originalPath)) { - Directory.CreateDirectory(Path.GetDirectoryName(originalPath)); + Directory.CreateDirectory(originalPath); } - if (!Directory.Exists(Path.GetDirectoryName(requestedPath))) + if (!Directory.Exists(requestedPath)) { - Directory.CreateDirectory(Path.GetDirectoryName(requestedPath)); + Directory.CreateDirectory(requestedPath); } // get the resolution attribute for enum size @@ -1147,7 +1147,7 @@ namespace gaseous_server.Classes.Metadata // get the original image Communications comms = new Communications(); - switch (_MetadataSource) + switch (SourceType) { case HasheousClient.Models.MetadataSources.None: await comms.API_GetURL(ImageId, originalPath); @@ -1180,7 +1180,7 @@ namespace gaseous_server.Classes.Metadata { image.Resize(resolution.X, resolution.Y); image.Strip(); - image.Write(requestedPath); + image.Write(requestedFilePath); } } diff --git a/gaseous-server/Controllers/V1.0/GamesController.cs b/gaseous-server/Controllers/V1.0/GamesController.cs index 2d4ab1a..4194630 100644 --- a/gaseous-server/Controllers/V1.0/GamesController.cs +++ b/gaseous-server/Controllers/V1.0/GamesController.cs @@ -578,7 +578,7 @@ namespace gaseous_server.Controllers if (!System.IO.File.Exists(imagePath)) { Communications comms = new Communications(); - Task ImgFetch = comms.GetSpecificImageFromServer(Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(game), imageTypePath), imageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); + Task ImgFetch = comms.GetSpecificImageFromServer(game.MetadataSource, Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(game), imageTypePath), imageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); imagePath = ImgFetch.Result; } @@ -586,7 +586,7 @@ namespace gaseous_server.Controllers if (!System.IO.File.Exists(imagePath)) { Communications comms = new Communications(); - Task ImgFetch = comms.GetSpecificImageFromServer(basePath, imageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); + Task ImgFetch = comms.GetSpecificImageFromServer(game.MetadataSource, basePath, imageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); imagePath = ImgFetch.Result; } diff --git a/gaseous-server/Controllers/V1.0/PlatformsController.cs b/gaseous-server/Controllers/V1.0/PlatformsController.cs index 60bbd6a..38ae1a5 100644 --- a/gaseous-server/Controllers/V1.0/PlatformsController.cs +++ b/gaseous-server/Controllers/V1.0/PlatformsController.cs @@ -155,7 +155,7 @@ namespace gaseous_server.Controllers if (!System.IO.File.Exists(imagePath)) { Communications comms = new Communications(); - Task ImgFetch = comms.GetSpecificImageFromServer(Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Platform(platformObject)), logoObject.ImageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); + Task ImgFetch = comms.GetSpecificImageFromServer(Communications.MetadataSource, Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Platform(platformObject)), logoObject.ImageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); imagePath = ImgFetch.Result; } @@ -163,7 +163,7 @@ namespace gaseous_server.Controllers if (!System.IO.File.Exists(imagePath)) { Communications comms = new Communications(); - Task ImgFetch = comms.GetSpecificImageFromServer(basePath, logoObject.ImageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); + Task ImgFetch = comms.GetSpecificImageFromServer(Communications.MetadataSource, basePath, logoObject.ImageId, size, new List { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original }); imagePath = ImgFetch.Result; } diff --git a/gaseous-server/Controllers/V1.0/SystemController.cs b/gaseous-server/Controllers/V1.0/SystemController.cs index 1c287fd..6726719 100644 --- a/gaseous-server/Controllers/V1.0/SystemController.cs +++ b/gaseous-server/Controllers/V1.0/SystemController.cs @@ -51,7 +51,19 @@ namespace gaseous_server.Controllers ReturnValue.DatabaseSize = (long)(System.Decimal)dbResponse.Rows[0][1]; // platform statistics - sql = "SELECT Platform.`name`, grc.Count, grs.Size FROM Platform INNER JOIN (SELECT Platform.`name` AS `Name`, SUM(grs.Size) AS Size FROM Platform JOIN view_Games_Roms AS grs ON (grs.PlatformId = Platform.Id) GROUP BY Platform.`name`) grs ON (grs.`Name` = Platform.`name`) INNER JOIN (SELECT Platform.`name` AS `Name`, COUNT(grc.Size) AS Count FROM Platform JOIN view_Games_Roms AS grc ON (grc.PlatformId = Platform.Id) GROUP BY Platform.`name`) grc ON (grc.`Name` = Platform.`name`) ORDER BY Platform.`name`;"; + sql = @" +SELECT + view_Games_Roms.PlatformId, + Platform.`Name`, + SUM(view_Games_Roms.Size) AS Size, + COUNT(view_Games_Roms.`Id`) AS Count +FROM + view_Games_Roms + LEFT JOIN + Platform ON view_Games_Roms.PlatformId = Platform.`Id` + AND Platform.SourceId = 0 +GROUP BY Platform.`Name` +ORDER BY Platform.`Name`; "; dbResponse = db.ExecuteCMD(sql); ReturnValue.PlatformStatistics = new List(); foreach (DataRow dr in dbResponse.Rows)