From c724d927bbbba11d7cf713a2978098a133a6156a Mon Sep 17 00:00:00 2001
From: Michael Green <84688932+michael-j-green@users.noreply.github.com>
Date: Thu, 19 Dec 2024 09:15:01 +1100
Subject: [PATCH] WIP
---
gaseous-server/Classes/FileSignature.cs | 28 ++++++++++++-------
gaseous-server/Classes/MetadataManagement.cs | 19 +++++++++++--
.../Controllers/V1.1/GamesController.cs | 2 +-
gaseous-server/gaseous-server.csproj | 2 +-
.../wwwroot/scripts/gamesformating.js | 4 +--
gaseous-server/wwwroot/scripts/uploadrom.js | 6 ++--
6 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/gaseous-server/Classes/FileSignature.cs b/gaseous-server/Classes/FileSignature.cs
index a9c4f81..b7b9946 100644
--- a/gaseous-server/Classes/FileSignature.cs
+++ b/gaseous-server/Classes/FileSignature.cs
@@ -2,7 +2,7 @@ using System.Collections.Concurrent;
using System.IO.Compression;
using System.Net;
using gaseous_server.Classes.Metadata;
-using HasheousClient.Models;
+using gaseous_server.Models;
using HasheousClient.Models.Metadata.IGDB;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using NuGet.Common;
@@ -199,7 +199,7 @@ namespace gaseous_server.Classes
else
{
determinedPlatform = Metadata.Platforms.GetPlatform((long)library.DefaultPlatformId);
- discoveredSignature.MetadataSources.AddPlatform((long)determinedPlatform.Id, determinedPlatform.Name, MetadataSources.None);
+ discoveredSignature.MetadataSources.AddPlatform((long)determinedPlatform.Id, determinedPlatform.Name, HasheousClient.Models.MetadataSources.None);
}
return discoveredSignature;
@@ -308,10 +308,10 @@ namespace gaseous_server.Classes
{
HasheousClient.Hasheous hasheous = new HasheousClient.Hasheous();
Console.WriteLine(HasheousClient.WebApp.HttpHelper.BaseUri);
- LookupItemModel? HasheousResult = null;
+ HasheousClient.Models.LookupItemModel? HasheousResult = null;
try
{
- HasheousResult = hasheous.RetrieveFromHasheous(new HashLookupModel
+ HasheousResult = hasheous.RetrieveFromHasheous(new HasheousClient.Models.HashLookupModel
{
MD5 = hash.md5hash,
SHA1 = hash.sha1hash
@@ -334,10 +334,14 @@ namespace gaseous_server.Classes
{
foreach (HasheousClient.Models.MetadataItem metadataResult in HasheousResult.Platform.metadata)
{
- if (metadataResult.Id.Length > 0)
+ // only IGDB metadata is supported
+ if (metadataResult.Source == HasheousClient.Models.MetadataSources.IGDB)
{
- Platform hasheousPlatform = Platforms.GetPlatform(metadataResult.Id);
- signature.MetadataSources.AddPlatform((long)hasheousPlatform.Id, hasheousPlatform.Name, metadataResult.Source);
+ if (metadataResult.Id.Length > 0)
+ {
+ Platform hasheousPlatform = Platforms.GetPlatform(metadataResult.Id);
+ signature.MetadataSources.AddPlatform((long)hasheousPlatform.Id, hasheousPlatform.Name, metadataResult.Source);
+ }
}
}
}
@@ -350,10 +354,14 @@ namespace gaseous_server.Classes
{
foreach (HasheousClient.Models.MetadataItem metadataResult in HasheousResult.Metadata)
{
- if (metadataResult.Id.Length > 0)
+ // only IGDB metadata is supported
+ if (metadataResult.Source == HasheousClient.Models.MetadataSources.IGDB)
{
- Game hasheousGame = Games.GetGame(MetadataSources.IGDB, metadataResult.Id);
- signature.MetadataSources.AddGame((long)hasheousGame.Id, hasheousGame.Name, metadataResult.Source);
+ if (metadataResult.Id.Length > 0)
+ {
+ gaseous_server.Models.Game hasheousGame = Games.GetGame(HasheousClient.Models.MetadataSources.IGDB, metadataResult.Id);
+ signature.MetadataSources.AddGame((long)hasheousGame.Id, hasheousGame.Name, metadataResult.Source);
+ }
}
}
}
diff --git a/gaseous-server/Classes/MetadataManagement.cs b/gaseous-server/Classes/MetadataManagement.cs
index 783d195..c24d200 100644
--- a/gaseous-server/Classes/MetadataManagement.cs
+++ b/gaseous-server/Classes/MetadataManagement.cs
@@ -9,6 +9,8 @@ namespace gaseous_server.Classes
{
public class MetadataManagement : QueueItemStatus
{
+ private static bool Processing = false;
+
///
/// Creates a new metadata map, if one with the same platformId and name does not already exist.
///
@@ -23,6 +25,16 @@ namespace gaseous_server.Classes
///
public static MetadataMap? NewMetadataMap(long platformId, string name)
{
+ if (Processing == true)
+ {
+ // loop until processing = false
+ while (Processing == true)
+ {
+ System.Threading.Thread.Sleep(500);
+ }
+ }
+ Processing = true;
+
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "";
Dictionary dbDict = new Dictionary()
@@ -36,6 +48,7 @@ namespace gaseous_server.Classes
MetadataMap? existingMetadataMap = GetMetadataMap(platformId, name);
if (existingMetadataMap != null)
{
+ Processing = false;
return existingMetadataMap;
}
@@ -62,7 +75,9 @@ namespace gaseous_server.Classes
AddMetadataMapItem(metadataMapId, HasheousClient.Models.MetadataSources.None, gameId, true);
// return the new metadata map
- return GetMetadataMap(metadataMapId);
+ MetadataMap RetVal = GetMetadataMap(metadataMapId);
+ Processing = false;
+ return RetVal;
}
///
@@ -129,7 +144,7 @@ namespace gaseous_server.Classes
Dictionary dbDict = new Dictionary()
{
{ "@platformId", platformId },
- { "@name", name }
+ { "@name", name.Trim() }
};
DataTable dt = new DataTable();
diff --git a/gaseous-server/Controllers/V1.1/GamesController.cs b/gaseous-server/Controllers/V1.1/GamesController.cs
index dc8ead3..f6b7813 100644
--- a/gaseous-server/Controllers/V1.1/GamesController.cs
+++ b/gaseous-server/Controllers/V1.1/GamesController.cs
@@ -550,7 +550,7 @@ FROM
LEFT JOIN
Relation_Game_Themes ON Game.Id = Relation_Game_Themes.GameId
LEFT JOIN
- Favourites ON Game.Id = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
+ Favourites ON Game.MetadataMapId = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
List RetVal = new List();
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
diff --git a/gaseous-server/gaseous-server.csproj b/gaseous-server/gaseous-server.csproj
index 25e5b06..8b3b9d6 100644
--- a/gaseous-server/gaseous-server.csproj
+++ b/gaseous-server/gaseous-server.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/gaseous-server/wwwroot/scripts/gamesformating.js b/gaseous-server/wwwroot/scripts/gamesformating.js
index 02a707e..c393c64 100644
--- a/gaseous-server/wwwroot/scripts/gamesformating.js
+++ b/gaseous-server/wwwroot/scripts/gamesformating.js
@@ -405,8 +405,6 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
showFavourite = true;
}
- console.log(gameObject);
-
let classes = getViewModeClasses(listView);
let gameBox = document.createElement('div');
@@ -532,7 +530,7 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
gameObject.isFavourite = true;
}
- fetch('/api/v1.1/Games/' + gameObject.metaDataMapId + '/favourite?favourite=' + gameObject.isFavourite, {
+ fetch('/api/v1.1/Games/' + gameObject.metadataMapId + '/favourite?favourite=' + gameObject.isFavourite, {
method: 'POST'
}).then(response => {
if (response.ok) {
diff --git a/gaseous-server/wwwroot/scripts/uploadrom.js b/gaseous-server/wwwroot/scripts/uploadrom.js
index d0da708..849617b 100644
--- a/gaseous-server/wwwroot/scripts/uploadrom.js
+++ b/gaseous-server/wwwroot/scripts/uploadrom.js
@@ -124,11 +124,11 @@ class UploadRom {
uploadedItem.romId = response.romid;
if (response.game) {
- uploadedItem.gameId = response.game.id;
+ uploadedItem.gameId = response.game.metadataMapId;
uploadedItem.gameName = response.game.name;
if (response.game.cover != null) {
- if (response.game.cover.id != null) {
- uploadedItem.coverId = response.game.cover.id;
+ if (response.game.cover != null) {
+ uploadedItem.coverId = response.game.cover;
}
}
}