Now pre-compiles age group metadata instead of generating it on every query (#235)
* Server will now quit on start up if schema updates fail (closes Abort start up if an error occurs during database upgrade #221) * Moved AgeGroups to it's own class * Improved query performance by defining the AgeGroupId as a metadata item. A metadata refresh is required to generate this data
This commit is contained in:
@@ -5,13 +5,13 @@ namespace Authentication
|
|||||||
public class SecurityProfileViewModel
|
public class SecurityProfileViewModel
|
||||||
{
|
{
|
||||||
public AgeRestrictionItem AgeRestrictionPolicy { get; set; } = new AgeRestrictionItem{
|
public AgeRestrictionItem AgeRestrictionPolicy { get; set; } = new AgeRestrictionItem{
|
||||||
MaximumAgeRestriction = gaseous_server.Classes.Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings.Adult,
|
MaximumAgeRestriction = gaseous_server.Classes.Metadata.AgeGroups.AgeRestrictionGroupings.Adult,
|
||||||
IncludeUnrated = true
|
IncludeUnrated = true
|
||||||
};
|
};
|
||||||
|
|
||||||
public class AgeRestrictionItem
|
public class AgeRestrictionItem
|
||||||
{
|
{
|
||||||
public gaseous_server.Classes.Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction { get; set; }
|
public gaseous_server.Classes.Metadata.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction { get; set; }
|
||||||
public bool IncludeUnrated { get; set; }
|
public bool IncludeUnrated { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -220,7 +220,7 @@ namespace gaseous_server.Classes
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get all platforms to pull from
|
// get all platforms to pull from
|
||||||
Dictionary<string, List<Filters.FilterItem>> FilterDict = Filters.Filter(AgeRatings.AgeGroups.AgeRestrictionGroupings.Adult, true);
|
Dictionary<string, List<Filters.FilterItem>> FilterDict = Filters.Filter(AgeGroups.AgeRestrictionGroupings.Adult, true);
|
||||||
List<Classes.Filters.FilterItem> filteredPlatforms = (List<Classes.Filters.FilterItem>)FilterDict["platforms"];
|
List<Classes.Filters.FilterItem> filteredPlatforms = (List<Classes.Filters.FilterItem>)FilterDict["platforms"];
|
||||||
foreach (Filters.FilterItem filterItem in filteredPlatforms) {
|
foreach (Filters.FilterItem filterItem in filteredPlatforms) {
|
||||||
platforms.Add(Platforms.GetPlatform(filterItem.Id));
|
platforms.Add(Platforms.GetPlatform(filterItem.Id));
|
||||||
|
@@ -106,13 +106,15 @@ namespace gaseous_server.Classes
|
|||||||
int SchemaVer = (int)SchemaVersion.Rows[0][0];
|
int SchemaVer = (int)SchemaVersion.Rows[0][0];
|
||||||
Logging.Log(Logging.LogType.Information, "Database", "Schema version is " + SchemaVer);
|
Logging.Log(Logging.LogType.Information, "Database", "Schema version is " + SchemaVer);
|
||||||
if (SchemaVer < i)
|
if (SchemaVer < i)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// run pre-upgrade code
|
// run pre-upgrade code
|
||||||
DatabaseMigration.PreUpgradeScript(i, _ConnectorType);
|
DatabaseMigration.PreUpgradeScript(i, _ConnectorType);
|
||||||
|
|
||||||
// apply schema!
|
// apply schema!
|
||||||
Logging.Log(Logging.LogType.Information, "Database", "Updating schema to version " + i);
|
Logging.Log(Logging.LogType.Information, "Database", "Updating schema to version " + i);
|
||||||
ExecuteCMD(dbScript, dbDict);
|
ExecuteCMD(dbScript, dbDict, 180);
|
||||||
|
|
||||||
sql = "UPDATE schema_version SET schema_version=@schemaver";
|
sql = "UPDATE schema_version SET schema_version=@schemaver";
|
||||||
dbDict = new Dictionary<string, object>();
|
dbDict = new Dictionary<string, object>();
|
||||||
@@ -122,6 +124,12 @@ namespace gaseous_server.Classes
|
|||||||
// run post-upgrade code
|
// run post-upgrade code
|
||||||
DatabaseMigration.PostUpgradeScript(i, _ConnectorType);
|
DatabaseMigration.PostUpgradeScript(i, _ConnectorType);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Critical, "Database", "Schema upgrade failed! Unable to continue.", ex);
|
||||||
|
System.Environment.Exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
public class Filters
|
public class Filters
|
||||||
{
|
{
|
||||||
public static Dictionary<string, List<FilterItem>> Filter(Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction, bool IncludeUnrated)
|
public static Dictionary<string, List<FilterItem>> Filter(Metadata.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction, bool IncludeUnrated)
|
||||||
{
|
{
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
@@ -90,13 +90,13 @@ namespace gaseous_server.Classes
|
|||||||
FilterItem filterAgeGrouping = new FilterItem();
|
FilterItem filterAgeGrouping = new FilterItem();
|
||||||
if (dr["AgeGroupId"] == DBNull.Value)
|
if (dr["AgeGroupId"] == DBNull.Value)
|
||||||
{
|
{
|
||||||
filterAgeGrouping.Id = (int)(long)AgeRatings.AgeGroups.AgeRestrictionGroupings.Unclassified;
|
filterAgeGrouping.Id = (int)(long)AgeGroups.AgeRestrictionGroupings.Unclassified;
|
||||||
filterAgeGrouping.Name = AgeRatings.AgeGroups.AgeRestrictionGroupings.Unclassified.ToString();
|
filterAgeGrouping.Name = AgeGroups.AgeRestrictionGroupings.Unclassified.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long ageGroupLong = (long)dr["AgeGroupId"];
|
int ageGroupLong = (int)dr["AgeGroupId"];
|
||||||
AgeRatings.AgeGroups.AgeRestrictionGroupings ageGroup = (AgeRatings.AgeGroups.AgeRestrictionGroupings)ageGroupLong;
|
AgeGroups.AgeRestrictionGroupings ageGroup = (AgeGroups.AgeRestrictionGroupings)ageGroupLong;
|
||||||
filterAgeGrouping.Id = ageGroupLong;
|
filterAgeGrouping.Id = ageGroupLong;
|
||||||
filterAgeGrouping.Name = ageGroup.ToString();
|
filterAgeGrouping.Name = ageGroup.ToString();
|
||||||
}
|
}
|
||||||
|
304
gaseous-server/Classes/Metadata/AgeGroups.cs
Normal file
304
gaseous-server/Classes/Metadata/AgeGroups.cs
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using IGDB;
|
||||||
|
using IGDB.Models;
|
||||||
|
using Microsoft.CodeAnalysis.Classification;
|
||||||
|
|
||||||
|
namespace gaseous_server.Classes.Metadata
|
||||||
|
{
|
||||||
|
public class AgeGroups
|
||||||
|
{
|
||||||
|
public AgeGroups()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AgeGroup? GetAgeGroup(Game? game)
|
||||||
|
{
|
||||||
|
if (game == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
|
||||||
|
cacheStatus = Storage.GetCacheStatus("AgeGroup", (long)game.Id);
|
||||||
|
|
||||||
|
AgeGroup? RetVal = new AgeGroup();
|
||||||
|
|
||||||
|
switch (cacheStatus)
|
||||||
|
{
|
||||||
|
case Storage.CacheStatus.NotPresent:
|
||||||
|
RetVal = _GetAgeGroup(game);
|
||||||
|
Storage.NewCacheValue(RetVal, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Storage.CacheStatus.Expired:
|
||||||
|
RetVal = _GetAgeGroup(game);
|
||||||
|
Storage.NewCacheValue(RetVal, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Storage.CacheStatus.Current:
|
||||||
|
RetVal = Storage.GetCacheValue<AgeGroup>(RetVal, "Id", game.Id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Exception("How did you get here?");
|
||||||
|
}
|
||||||
|
|
||||||
|
return RetVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AgeGroup? _GetAgeGroup(Game game)
|
||||||
|
{
|
||||||
|
// compile the maximum age group for the given game
|
||||||
|
if (game != null)
|
||||||
|
{
|
||||||
|
if (game.AgeRatings != null)
|
||||||
|
{
|
||||||
|
if (game.AgeRatings.Ids != null)
|
||||||
|
{
|
||||||
|
// collect ratings values from metadata
|
||||||
|
List<AgeRating> ageRatings = new List<AgeRating>();
|
||||||
|
foreach (long ratingId in game.AgeRatings.Ids)
|
||||||
|
{
|
||||||
|
AgeRating? rating = AgeRatings.GetAgeRatings(ratingId);
|
||||||
|
if (rating != null)
|
||||||
|
{
|
||||||
|
ageRatings.Add(rating);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// compile the ratings values into the ratings groups
|
||||||
|
AgeRestrictionGroupings highestAgeGroup = AgeRestrictionGroupings.Unclassified;
|
||||||
|
foreach (AgeRating ageRating in ageRatings)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<AgeRestrictionGroupings, AgeGroupItem> ageGroupItem in AgeGroupingsFlat)
|
||||||
|
{
|
||||||
|
|
||||||
|
PropertyInfo[] groupProps = typeof(AgeGroupItem).GetProperties();
|
||||||
|
foreach (PropertyInfo property in groupProps)
|
||||||
|
{
|
||||||
|
if (RatingsBoards.Contains(property.Name))
|
||||||
|
{
|
||||||
|
List<AgeRatingTitle> ratingBoard = (List<AgeRatingTitle>)property.GetValue(ageGroupItem.Value);
|
||||||
|
foreach (AgeRatingTitle ratingTitle in ratingBoard)
|
||||||
|
{
|
||||||
|
if (ageRating.Rating == ratingTitle)
|
||||||
|
{
|
||||||
|
if (highestAgeGroup < ageGroupItem.Key)
|
||||||
|
{
|
||||||
|
highestAgeGroup = ageGroupItem.Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the compiled ratings group
|
||||||
|
AgeGroup ageGroup = new AgeGroup();
|
||||||
|
ageGroup.Id = game.Id;
|
||||||
|
ageGroup.GameId = game.Id;
|
||||||
|
if (highestAgeGroup == 0)
|
||||||
|
{
|
||||||
|
ageGroup.AgeGroupId = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ageGroup.AgeGroupId = highestAgeGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ageGroup;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AgeGroup ageGroup = new AgeGroup();
|
||||||
|
ageGroup.Id = game.Id;
|
||||||
|
ageGroup.GameId = game.Id;
|
||||||
|
ageGroup.AgeGroupId = null;
|
||||||
|
|
||||||
|
return ageGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AgeGroup ageGroup = new AgeGroup();
|
||||||
|
ageGroup.Id = game.Id;
|
||||||
|
ageGroup.GameId = game.Id;
|
||||||
|
ageGroup.AgeGroupId = null;
|
||||||
|
|
||||||
|
return ageGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AgeGroup
|
||||||
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
|
public long? GameId { get; set; }
|
||||||
|
public AgeRestrictionGroupings? AgeGroupId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<AgeRestrictionGroupings, List<AgeGroupItem>> AgeGroupings
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Dictionary<AgeRestrictionGroupings, List<AgeGroupItem>>{
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Adult, new List<AgeGroupItem>{ Adult_Item, Mature_Item, Teen_Item, Child_Item }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Mature, new List<AgeGroupItem>{ Mature_Item, Teen_Item, Child_Item }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Teen, new List<AgeGroupItem>{ Teen_Item, Child_Item }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Child, new List<AgeGroupItem>{ Child_Item }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<AgeRestrictionGroupings, AgeGroupItem> AgeGroupingsFlat
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Dictionary<AgeRestrictionGroupings, AgeGroupItem>{
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Adult, Adult_Item
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Mature, Mature_Item
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Teen, Teen_Item
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AgeRestrictionGroupings.Child, Child_Item
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AgeRestrictionGroupings
|
||||||
|
{
|
||||||
|
Adult = 4,
|
||||||
|
Mature = 3,
|
||||||
|
Teen = 2,
|
||||||
|
Child = 1,
|
||||||
|
Unclassified = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> RatingsBoards
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<string> boards = new List<string>{
|
||||||
|
"ACB", "CERO", "CLASS_IND", "ESRB", "GRAC", "PEGI", "USK"
|
||||||
|
};
|
||||||
|
|
||||||
|
return boards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly static AgeGroupItem Adult_Item = new AgeGroupItem{
|
||||||
|
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_R18, AgeRatingTitle.ACB_RC },
|
||||||
|
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_Z },
|
||||||
|
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Eighteen },
|
||||||
|
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.RP, AgeRatingTitle.AO },
|
||||||
|
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Eighteen },
|
||||||
|
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Eighteen},
|
||||||
|
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_18}
|
||||||
|
};
|
||||||
|
|
||||||
|
readonly static AgeGroupItem Mature_Item = new AgeGroupItem{
|
||||||
|
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_M, AgeRatingTitle.ACB_MA15 },
|
||||||
|
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_C, AgeRatingTitle.CERO_D },
|
||||||
|
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Sixteen },
|
||||||
|
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.M },
|
||||||
|
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Fifteen },
|
||||||
|
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Sixteen},
|
||||||
|
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_16}
|
||||||
|
};
|
||||||
|
|
||||||
|
readonly static AgeGroupItem Teen_Item = new AgeGroupItem{
|
||||||
|
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_PG },
|
||||||
|
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_B },
|
||||||
|
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Twelve, AgeRatingTitle.CLASS_IND_Fourteen },
|
||||||
|
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.T },
|
||||||
|
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Twelve },
|
||||||
|
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Twelve},
|
||||||
|
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_12}
|
||||||
|
};
|
||||||
|
|
||||||
|
readonly static AgeGroupItem Child_Item = new AgeGroupItem{
|
||||||
|
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_G },
|
||||||
|
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_A },
|
||||||
|
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_L, AgeRatingTitle.CLASS_IND_Ten },
|
||||||
|
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.E, AgeRatingTitle.E10 },
|
||||||
|
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_All },
|
||||||
|
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Three, AgeRatingTitle.Seven},
|
||||||
|
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_0, AgeRatingTitle.USK_6}
|
||||||
|
};
|
||||||
|
|
||||||
|
public class AgeGroupItem
|
||||||
|
{
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> ACB { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> CERO { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> CLASS_IND { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> ESRB { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> GRAC { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> PEGI { get; set; }
|
||||||
|
public List<IGDB.Models.AgeRatingTitle> USK { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[Newtonsoft.Json.JsonIgnore]
|
||||||
|
public List<long> AgeGroupItemValues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<long> values = new List<long>();
|
||||||
|
{
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in ACB)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in CERO)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in CLASS_IND)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in ESRB)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in GRAC)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in PEGI)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
foreach (AgeRatingTitle ageRatingTitle in USK)
|
||||||
|
{
|
||||||
|
values.Add((long)ageRatingTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -186,158 +186,6 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AgeGroups
|
|
||||||
{
|
|
||||||
public AgeGroups()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Dictionary<AgeRestrictionGroupings, List<AgeGroupItem>> AgeGroupings
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new Dictionary<AgeRestrictionGroupings, List<AgeGroupItem>>{
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Adult, new List<AgeGroupItem>{ Adult_Item, Mature_Item, Teen_Item, Child_Item }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Mature, new List<AgeGroupItem>{ Mature_Item, Teen_Item, Child_Item }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Teen, new List<AgeGroupItem>{ Teen_Item, Child_Item }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Child, new List<AgeGroupItem>{ Child_Item }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Dictionary<AgeRestrictionGroupings, AgeGroupItem> AgeGroupingsFlat
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new Dictionary<AgeRestrictionGroupings, AgeGroupItem>{
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Adult, Adult_Item
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Mature, Mature_Item
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Teen, Teen_Item
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AgeRestrictionGroupings.Child, Child_Item
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum AgeRestrictionGroupings
|
|
||||||
{
|
|
||||||
Adult = 4,
|
|
||||||
Mature = 3,
|
|
||||||
Teen = 2,
|
|
||||||
Child = 1,
|
|
||||||
Unclassified = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly static AgeGroupItem Adult_Item = new AgeGroupItem{
|
|
||||||
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_R18, AgeRatingTitle.ACB_RC },
|
|
||||||
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_Z },
|
|
||||||
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Eighteen },
|
|
||||||
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.RP, AgeRatingTitle.AO },
|
|
||||||
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Eighteen },
|
|
||||||
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Eighteen},
|
|
||||||
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_18}
|
|
||||||
};
|
|
||||||
|
|
||||||
readonly static AgeGroupItem Mature_Item = new AgeGroupItem{
|
|
||||||
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_M, AgeRatingTitle.ACB_MA15 },
|
|
||||||
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_C, AgeRatingTitle.CERO_D },
|
|
||||||
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Sixteen },
|
|
||||||
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.M },
|
|
||||||
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Fifteen },
|
|
||||||
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Sixteen},
|
|
||||||
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_16}
|
|
||||||
};
|
|
||||||
|
|
||||||
readonly static AgeGroupItem Teen_Item = new AgeGroupItem{
|
|
||||||
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_PG },
|
|
||||||
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_B },
|
|
||||||
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_Twelve, AgeRatingTitle.CLASS_IND_Fourteen },
|
|
||||||
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.T },
|
|
||||||
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_Twelve },
|
|
||||||
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Twelve},
|
|
||||||
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_12}
|
|
||||||
};
|
|
||||||
|
|
||||||
readonly static AgeGroupItem Child_Item = new AgeGroupItem{
|
|
||||||
ACB = new List<AgeRatingTitle>{ AgeRatingTitle.ACB_G },
|
|
||||||
CERO = new List<AgeRatingTitle>{ AgeRatingTitle.CERO_A },
|
|
||||||
CLASS_IND = new List<AgeRatingTitle>{ AgeRatingTitle.CLASS_IND_L, AgeRatingTitle.CLASS_IND_Ten },
|
|
||||||
ESRB = new List<AgeRatingTitle>{ AgeRatingTitle.E, AgeRatingTitle.E10 },
|
|
||||||
GRAC = new List<AgeRatingTitle>{ AgeRatingTitle.GRAC_All },
|
|
||||||
PEGI = new List<AgeRatingTitle>{ AgeRatingTitle.Three, AgeRatingTitle.Seven},
|
|
||||||
USK = new List<AgeRatingTitle>{ AgeRatingTitle.USK_0, AgeRatingTitle.USK_6}
|
|
||||||
};
|
|
||||||
|
|
||||||
public class AgeGroupItem
|
|
||||||
{
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> ACB { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> CERO { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> CLASS_IND { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> ESRB { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> GRAC { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> PEGI { get; set; }
|
|
||||||
public List<IGDB.Models.AgeRatingTitle> USK { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
[Newtonsoft.Json.JsonIgnore]
|
|
||||||
public List<long> AgeGroupItemValues
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<long> values = new List<long>();
|
|
||||||
{
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in ACB)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in CERO)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in CLASS_IND)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in ESRB)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in GRAC)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in PEGI)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
foreach (AgeRatingTitle ageRatingTitle in USK)
|
|
||||||
{
|
|
||||||
values.Add((long)ageRatingTitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -114,7 +114,9 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
case Storage.CacheStatus.Current:
|
case Storage.CacheStatus.Current:
|
||||||
return Storage.GetCacheValue<Game>(returnValue, "id", (long)searchValue);
|
returnValue = Storage.GetCacheValue<Game>(returnValue, "id", (long)searchValue);
|
||||||
|
UpdateSubClasses(returnValue, false, false);
|
||||||
|
return returnValue;
|
||||||
default:
|
default:
|
||||||
throw new Exception("How did you get here?");
|
throw new Exception("How did you get here?");
|
||||||
}
|
}
|
||||||
@@ -124,9 +126,16 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
{
|
{
|
||||||
// required metadata
|
// required metadata
|
||||||
if (Game.Cover != null)
|
if (Game.Cover != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch cover artwork.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Game.Genres != null)
|
if (Game.Genres != null)
|
||||||
{
|
{
|
||||||
@@ -175,6 +184,7 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
AgeRating GameAgeRating = AgeRatings.GetAgeRatings(AgeRatingId);
|
AgeRating GameAgeRating = AgeRatings.GetAgeRatings(AgeRatingId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AgeGroups.GetAgeGroup(Game);
|
||||||
|
|
||||||
if (Game.ReleaseDates != null)
|
if (Game.ReleaseDates != null)
|
||||||
{
|
{
|
||||||
@@ -198,9 +208,16 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
if (Game.Artworks != null)
|
if (Game.Artworks != null)
|
||||||
{
|
{
|
||||||
foreach (long ArtworkId in Game.Artworks.Ids)
|
foreach (long ArtworkId in Game.Artworks.Ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch artwork id: " + ArtworkId, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (followSubGames)
|
if (followSubGames)
|
||||||
@@ -265,9 +282,16 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
if (Game.Screenshots != null)
|
if (Game.Screenshots != null)
|
||||||
{
|
{
|
||||||
foreach (long ScreenshotId in Game.Screenshots.Ids)
|
foreach (long ScreenshotId in Game.Screenshots.Ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch screenshot id: " + ScreenshotId, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Game.Videos != null)
|
if (Game.Videos != null)
|
||||||
|
@@ -375,6 +375,9 @@ namespace gaseous_server.Classes.Metadata
|
|||||||
case "[igdb.models.releasedatecategory":
|
case "[igdb.models.releasedatecategory":
|
||||||
property.SetValue(EndpointType, (ReleaseDateCategory)dataRow[property.Name]);
|
property.SetValue(EndpointType, (ReleaseDateCategory)dataRow[property.Name]);
|
||||||
break;
|
break;
|
||||||
|
case "[gaseous_server.classes.metadata.agegroups+agerestrictiongroupings":
|
||||||
|
property.SetValue(EndpointType, (AgeGroups.AgeRestrictionGroupings)dataRow[property.Name]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
property.SetValue(EndpointType, dataRow[property.Name]);
|
property.SetValue(EndpointType, dataRow[property.Name]);
|
||||||
break;
|
break;
|
||||||
|
@@ -103,7 +103,7 @@ namespace gaseous_server.Controllers
|
|||||||
"var AgeRatingStrings = " + JsonSerializer.Serialize(AgeRatingsStrings, new JsonSerializerOptions{
|
"var AgeRatingStrings = " + JsonSerializer.Serialize(AgeRatingsStrings, new JsonSerializerOptions{
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
}) + ";" + Environment.NewLine +
|
}) + ";" + Environment.NewLine +
|
||||||
"var AgeRatingGroups = " + JsonSerializer.Serialize(AgeRatings.AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{
|
"var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
}) + ";";
|
}) + ";";
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(ver);
|
byte[] bytes = Encoding.UTF8.GetBytes(ver);
|
||||||
|
@@ -113,6 +113,7 @@ namespace gaseous_server
|
|||||||
_CorrelationId = correlationId.ToString();
|
_CorrelationId = correlationId.ToString();
|
||||||
CallContext.SetData("CorrelationId", correlationId);
|
CallContext.SetData("CorrelationId", correlationId);
|
||||||
CallContext.SetData("CallingProcess", _ItemType.ToString());
|
CallContext.SetData("CallingProcess", _ItemType.ToString());
|
||||||
|
CallContext.SetData("CallingUser", "System");
|
||||||
|
|
||||||
// log the start
|
// log the start
|
||||||
Logging.Log(Logging.LogType.Debug, "Timered Event", "Executing " + _ItemType + " with correlation id " + _CorrelationId);
|
Logging.Log(Logging.LogType.Debug, "Timered Event", "Executing " + _ItemType + " with correlation id " + _CorrelationId);
|
||||||
|
18
gaseous-server/Support/Database/MySQL/gaseous-1011.sql
Normal file
18
gaseous-server/Support/Database/MySQL/gaseous-1011.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
CREATE TABLE `AgeGroup` (
|
||||||
|
`Id` BIGINT NOT NULL,
|
||||||
|
`GameId` BIGINT NULL,
|
||||||
|
`AgeGroupId` INT NULL,
|
||||||
|
`dateAdded` DATETIME NULL DEFAULT NULL,
|
||||||
|
`lastUpdated` DATETIME NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`Id`));
|
||||||
|
|
||||||
|
ALTER TABLE `Game`
|
||||||
|
CHANGE COLUMN `Slug` `Slug` VARCHAR(255) NULL DEFAULT NULL;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW `view_Games` AS
|
||||||
|
SELECT
|
||||||
|
a.*, b.AgeGroupId
|
||||||
|
FROM
|
||||||
|
view_GamesWithRoms a
|
||||||
|
LEFT JOIN AgeGroup b ON b.GameId = a.Id
|
||||||
|
ORDER BY NameThe;
|
@@ -51,6 +51,7 @@
|
|||||||
<None Remove="Support\Database\MySQL\gaseous-1008.sql" />
|
<None Remove="Support\Database\MySQL\gaseous-1008.sql" />
|
||||||
<None Remove="Support\Database\MySQL\gaseous-1009.sql" />
|
<None Remove="Support\Database\MySQL\gaseous-1009.sql" />
|
||||||
<None Remove="Support\Database\MySQL\gaseous-1010.sql" />
|
<None Remove="Support\Database\MySQL\gaseous-1010.sql" />
|
||||||
|
<None Remove="Support\Database\MySQL\gaseous-1011.sql" />
|
||||||
<None Remove="Classes\Metadata\" />
|
<None Remove="Classes\Metadata\" />
|
||||||
<None Remove="Assets\" />
|
<None Remove="Assets\" />
|
||||||
<None Remove="Assets\Ratings\" />
|
<None Remove="Assets\Ratings\" />
|
||||||
@@ -184,5 +185,6 @@
|
|||||||
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1008.sql" />
|
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1008.sql" />
|
||||||
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1009.sql" />
|
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1009.sql" />
|
||||||
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1010.sql" />
|
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1010.sql" />
|
||||||
|
<EmbeddedResource Include="Support\Database\MySQL\gaseous-1011.sql" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -196,8 +196,22 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#properties_fixgame').select2({
|
$('#properties_fixplatform').on('select2:select', function (e) {
|
||||||
|
var platformData = e.params.data;
|
||||||
|
console.log(platformData);
|
||||||
|
|
||||||
|
var gameValue = $('#properties_fixgame').select2('data');
|
||||||
|
if (gameValue) {
|
||||||
|
console.log(gameValue[0]);
|
||||||
|
|
||||||
|
setFixGameDropDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function setFixGameDropDown() {
|
||||||
|
$('#properties_fixgame').empty().select2({
|
||||||
minimumInputLength: 3,
|
minimumInputLength: 3,
|
||||||
|
placeholder: 'Game',
|
||||||
templateResult: DropDownRenderGameOption,
|
templateResult: DropDownRenderGameOption,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '/api/v1.1/Search/Game',
|
url: '/api/v1.1/Search/Game',
|
||||||
@@ -229,6 +243,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
setFixGameDropDown();
|
||||||
|
|
||||||
function SaveFixedGame() {
|
function SaveFixedGame() {
|
||||||
var fixplatform = $('#properties_fixplatform').select2('data');
|
var fixplatform = $('#properties_fixplatform').select2('data');
|
||||||
|
@@ -741,7 +741,20 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#rom_edit_fixgame').select2({
|
$('#rom_edit_fixplatform').on('select2:select', function (e) {
|
||||||
|
var platformData = e.params.data;
|
||||||
|
console.log(platformData);
|
||||||
|
|
||||||
|
var gameValue = $('#rom_edit_fixgame').select2('data');
|
||||||
|
if (gameValue) {
|
||||||
|
console.log(gameValue[0]);
|
||||||
|
|
||||||
|
setRomFixGameDropDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function setRomFixGameDropDown() {
|
||||||
|
$('#rom_edit_fixgame').empty().select2({
|
||||||
minimumInputLength: 3,
|
minimumInputLength: 3,
|
||||||
templateResult: DropDownRenderGameOption,
|
templateResult: DropDownRenderGameOption,
|
||||||
placeholder: "Game",
|
placeholder: "Game",
|
||||||
@@ -775,6 +788,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
setRomFixGameDropDown();
|
||||||
|
|
||||||
var remapCallCounter = 0;
|
var remapCallCounter = 0;
|
||||||
var remapCallCounterMax = 0;
|
var remapCallCounterMax = 0;
|
||||||
|
Reference in New Issue
Block a user