From 9e93ed1041ed0ea0ff83d7d32f591430f9c8597e Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Thu, 9 Jan 2025 01:54:24 +1100 Subject: [PATCH] WIP --- gaseous-server/Classes/Metadata/Metadata.cs | 36 +++++++++++++------ .../Controllers/V1.0/GamesController.cs | 3 ++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gaseous-server/Classes/Metadata/Metadata.cs b/gaseous-server/Classes/Metadata/Metadata.cs index 1610275..df673e6 100644 --- a/gaseous-server/Classes/Metadata/Metadata.cs +++ b/gaseous-server/Classes/Metadata/Metadata.cs @@ -138,27 +138,43 @@ namespace gaseous_server.Classes.Metadata break; case Storage.CacheStatus.Expired: - if (idType == IdType.Long) + try { - metadata = GetMetadataFromServer(SourceType, (long)Id).Result; + if (idType == IdType.Long) + { + metadata = GetMetadataFromServer(SourceType, (long)Id).Result; + } + else + { + metadata = GetMetadataFromServer(SourceType, (string)Id).Result; + } + Storage.NewCacheValue(SourceType, metadata, true); } - else + catch (Exception e) { - metadata = GetMetadataFromServer(SourceType, (string)Id).Result; + Logging.Log(Logging.LogType.Warning, "Fetch Metadata", "Failed to fetch metadata from source: " + SourceType + " for id: " + Id + " of type: " + type + ". Error: " + e.Message); + metadata = null; } - Storage.NewCacheValue(SourceType, metadata, true); break; case Storage.CacheStatus.NotPresent: - if (idType == IdType.Long) + try { - metadata = GetMetadataFromServer(SourceType, (long)Id).Result; + if (idType == IdType.Long) + { + metadata = GetMetadataFromServer(SourceType, (long)Id).Result; + } + else + { + metadata = GetMetadataFromServer(SourceType, (string)Id).Result; + } + Storage.NewCacheValue(SourceType, metadata, false); } - else + catch (Exception e) { - metadata = GetMetadataFromServer(SourceType, (string)Id).Result; + Logging.Log(Logging.LogType.Warning, "Fetch Metadata", "Failed to fetch metadata from source: " + SourceType + " for id: " + Id + " of type: " + type + ". Error: " + e.Message); + metadata = null; } - Storage.NewCacheValue(SourceType, metadata, false); break; } diff --git a/gaseous-server/Controllers/V1.0/GamesController.cs b/gaseous-server/Controllers/V1.0/GamesController.cs index 6066182..982ec62 100644 --- a/gaseous-server/Controllers/V1.0/GamesController.cs +++ b/gaseous-server/Controllers/V1.0/GamesController.cs @@ -808,6 +808,9 @@ namespace gaseous_server.Controllers MetadataMap filteredMetadataMap = new MetadataMap(); filteredMetadataMap.MetadataMapItems = metadataMap.MetadataMapItems.Where(x => x.SourceType != HasheousClient.Models.MetadataSources.TheGamesDb).ToList(); + // further filter out metadataMapItems where sourceId = 0 + filteredMetadataMap.MetadataMapItems = filteredMetadataMap.MetadataMapItems.Where(x => x.SourceId != 0).ToList(); + metadataMap.MetadataMapItems = filteredMetadataMap.MetadataMapItems; return Ok(metadataMap);