mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify status count statistics
This commit is contained in:
@@ -118,28 +118,16 @@ namespace SabreTools.DatFiles
|
|||||||
public long TotalSize { get; private set; } = 0;
|
public long TotalSize { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of hashes for each hash type
|
/// Number of items for each hash type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public Dictionary<Hash, long> HashCounts { get; private set; } = [];
|
public Dictionary<Hash, long> HashCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the baddump status
|
/// Number of items for each item status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long BaddumpCount { get; private set; } = 0;
|
public Dictionary<ItemStatus, long> StatusCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the good status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long GoodCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the nodump status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long NodumpCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the remove flag
|
/// Number of items with the remove flag
|
||||||
@@ -147,12 +135,6 @@ namespace SabreTools.DatFiles
|
|||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long RemovedCount { get; private set; } = 0;
|
public long RemovedCount { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the verified status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long VerifiedCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -250,10 +232,10 @@ namespace SabreTools.DatFiles
|
|||||||
AddHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
AddHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
AddStatusCount(ItemStatus.BadDump, disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount += (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
AddStatusCount(ItemStatus.Good, disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
AddStatusCount(ItemStatus.Nodump, disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
AddStatusCount(ItemStatus.Verified, disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Media media:
|
case Media media:
|
||||||
AddHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
AddHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
@@ -274,10 +256,10 @@ namespace SabreTools.DatFiles
|
|||||||
AddHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
AddHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
AddStatusCount(ItemStatus.BadDump, rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount += (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
AddStatusCount(ItemStatus.Good, rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
AddStatusCount(ItemStatus.Nodump, rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
AddStatusCount(ItemStatus.Verified, rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,11 +318,12 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Individual status counts
|
// Individual status counts
|
||||||
BaddumpCount += stats.BaddumpCount;
|
foreach (var statusCountKvp in stats.StatusCounts)
|
||||||
GoodCount += stats.GoodCount;
|
{
|
||||||
NodumpCount += stats.NodumpCount;
|
AddStatusCount(statusCountKvp.Key, statusCountKvp.Value);
|
||||||
|
}
|
||||||
|
|
||||||
RemovedCount += stats.RemovedCount;
|
RemovedCount += stats.RemovedCount;
|
||||||
VerifiedCount += stats.VerifiedCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -530,10 +513,10 @@ namespace SabreTools.DatFiles
|
|||||||
RemoveHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
RemoveHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.BadDump, disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount -= (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Good, disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Nodump, disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Verified, disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Media media:
|
case Media media:
|
||||||
RemoveHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
RemoveHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
@@ -554,10 +537,10 @@ namespace SabreTools.DatFiles
|
|||||||
RemoveHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
RemoveHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.BadDump, rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount -= (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Good, rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Nodump, rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Verified, rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -595,6 +578,22 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the item count for a given item status, defaulting to 0 if it does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item status to retrieve</param>
|
||||||
|
/// <returns>The number of items of that type, if it exists</returns>
|
||||||
|
public long GetStatusCount(ItemStatus itemStatus)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return StatusCounts[itemStatus];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Increment the hash count for a given hash type
|
/// Increment the hash count for a given hash type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -667,6 +666,42 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increment the item count for a given item status
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item type to increment</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void AddStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
|
||||||
|
StatusCounts[itemStatus] += interval;
|
||||||
|
if (StatusCounts[itemStatus] < 0)
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decrement the item count for a given item status
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item type to decrement</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void RemoveStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
return;
|
||||||
|
|
||||||
|
StatusCounts[itemStatus] -= interval;
|
||||||
|
if (StatusCounts[itemStatus] < 0)
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -984,12 +1019,8 @@ namespace SabreTools.DatFiles
|
|||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
TotalSize = 0;
|
TotalSize = 0;
|
||||||
HashCounts = [];
|
HashCounts = [];
|
||||||
|
StatusCounts = [];
|
||||||
BaddumpCount = 0;
|
|
||||||
GoodCount = 0;
|
|
||||||
NodumpCount = 0;
|
|
||||||
RemovedCount = 0;
|
RemovedCount = 0;
|
||||||
VerifiedCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -997,29 +1028,30 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey GetBestAvailable()
|
private ItemKey GetBestAvailable()
|
||||||
{
|
{
|
||||||
// Get the item counts for the 3 hashable types
|
// Get the required counts
|
||||||
long diskCount = GetItemCount(ItemType.Disk);
|
long diskCount = GetItemCount(ItemType.Disk);
|
||||||
long mediaCount = GetItemCount(ItemType.Media);
|
long mediaCount = GetItemCount(ItemType.Media);
|
||||||
long romCount = GetItemCount(ItemType.Rom);
|
long romCount = GetItemCount(ItemType.Rom);
|
||||||
|
long nodumpCount = GetStatusCount(ItemStatus.Nodump);
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-512, we bucket by that
|
// If all items are supposed to have a SHA-512, we bucket by that
|
||||||
if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA512))
|
if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA512))
|
||||||
return ItemKey.SHA512;
|
return ItemKey.SHA512;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-384, we bucket by that
|
// If all items are supposed to have a SHA-384, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA384))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA384))
|
||||||
return ItemKey.SHA384;
|
return ItemKey.SHA384;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-256, we bucket by that
|
// If all items are supposed to have a SHA-256, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA256))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA256))
|
||||||
return ItemKey.SHA256;
|
return ItemKey.SHA256;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-1, we bucket by that
|
// If all items are supposed to have a SHA-1, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA1))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA1))
|
||||||
return ItemKey.SHA1;
|
return ItemKey.SHA1;
|
||||||
|
|
||||||
// If all items are supposed to have a MD5, we bucket by that
|
// If all items are supposed to have a MD5, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.MD5))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.MD5))
|
||||||
return ItemKey.MD5;
|
return ItemKey.MD5;
|
||||||
|
|
||||||
// Otherwise, we bucket by CRC
|
// Otherwise, we bucket by CRC
|
||||||
|
|||||||
@@ -182,22 +182,10 @@ namespace SabreTools.DatFiles
|
|||||||
public Dictionary<Hash, long> HashCounts { get; private set; } = [];
|
public Dictionary<Hash, long> HashCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the baddump status
|
/// Number of items for each item status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long BaddumpCount { get; private set; } = 0;
|
public Dictionary<ItemStatus, long> StatusCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the good status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long GoodCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the nodump status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long NodumpCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the remove flag
|
/// Number of items with the remove flag
|
||||||
@@ -205,12 +193,6 @@ namespace SabreTools.DatFiles
|
|||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long RemovedCount { get; private set; } = 0;
|
public long RemovedCount { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items with the verified status
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long VerifiedCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -369,10 +351,10 @@ namespace SabreTools.DatFiles
|
|||||||
AddHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
AddHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
AddStatusCount(ItemStatus.BadDump, disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount += (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
AddStatusCount(ItemStatus.Good, disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
AddStatusCount(ItemStatus.Nodump, disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
AddStatusCount(ItemStatus.Verified, disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Media media:
|
case Media media:
|
||||||
AddHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
AddHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
@@ -393,10 +375,10 @@ namespace SabreTools.DatFiles
|
|||||||
AddHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
AddHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
AddStatusCount(ItemStatus.BadDump, rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount += (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
AddStatusCount(ItemStatus.Good, rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
AddStatusCount(ItemStatus.Nodump, rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
AddStatusCount(ItemStatus.Verified, rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,11 +440,12 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Individual status counts
|
// Individual status counts
|
||||||
BaddumpCount += stats.BaddumpCount;
|
foreach (var statusCountKvp in stats.StatusCounts)
|
||||||
GoodCount += stats.GoodCount;
|
{
|
||||||
NodumpCount += stats.NodumpCount;
|
AddStatusCount(statusCountKvp.Key, statusCountKvp.Value);
|
||||||
|
}
|
||||||
|
|
||||||
RemovedCount += stats.RemovedCount;
|
RemovedCount += stats.RemovedCount;
|
||||||
VerifiedCount += stats.VerifiedCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -676,10 +659,10 @@ namespace SabreTools.DatFiles
|
|||||||
RemoveHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
RemoveHashCount(Hash.SHA1, string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.BadDump, disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount -= (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Good, disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Nodump, disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Verified, disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Media media:
|
case Media media:
|
||||||
RemoveHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
RemoveHashCount(Hash.MD5, string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
@@ -700,10 +683,10 @@ namespace SabreTools.DatFiles
|
|||||||
RemoveHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
RemoveHashCount(Hash.SpamSum, string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.BadDump, rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
GoodCount -= (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Good, rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Nodump, rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
RemoveStatusCount(ItemStatus.Verified, rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -741,6 +724,22 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the item count for a given item status, defaulting to 0 if it does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item status to retrieve</param>
|
||||||
|
/// <returns>The number of items of that type, if it exists</returns>
|
||||||
|
public long GetStatusCount(ItemStatus itemStatus)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return StatusCounts[itemStatus];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Increment the hash count for a given hash type
|
/// Increment the hash count for a given hash type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -813,6 +812,42 @@ namespace SabreTools.DatFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increment the item count for a given item status
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item type to increment</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void AddStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
|
||||||
|
StatusCounts[itemStatus] += interval;
|
||||||
|
if (StatusCounts[itemStatus] < 0)
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decrement the item count for a given item status
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemStatus">Item type to decrement</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void RemoveStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (StatusCounts)
|
||||||
|
{
|
||||||
|
if (!StatusCounts.ContainsKey(itemStatus))
|
||||||
|
return;
|
||||||
|
|
||||||
|
StatusCounts[itemStatus] -= interval;
|
||||||
|
if (StatusCounts[itemStatus] < 0)
|
||||||
|
StatusCounts[itemStatus] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -1155,12 +1190,8 @@ CREATE TABLE IF NOT EXISTS groups (
|
|||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
TotalSize = 0;
|
TotalSize = 0;
|
||||||
HashCounts = [];
|
HashCounts = [];
|
||||||
|
StatusCounts = [];
|
||||||
BaddumpCount = 0;
|
|
||||||
GoodCount = 0;
|
|
||||||
NodumpCount = 0;
|
|
||||||
RemovedCount = 0;
|
RemovedCount = 0;
|
||||||
VerifiedCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1168,29 +1199,30 @@ CREATE TABLE IF NOT EXISTS groups (
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey GetBestAvailable()
|
private ItemKey GetBestAvailable()
|
||||||
{
|
{
|
||||||
// Get the item counts for the 3 hashable types
|
// Get the required counts
|
||||||
long diskCount = GetItemCount(ItemType.Disk);
|
long diskCount = GetItemCount(ItemType.Disk);
|
||||||
long mediaCount = GetItemCount(ItemType.Media);
|
long mediaCount = GetItemCount(ItemType.Media);
|
||||||
long romCount = GetItemCount(ItemType.Rom);
|
long romCount = GetItemCount(ItemType.Rom);
|
||||||
|
long nodumpCount = GetStatusCount(ItemStatus.Nodump);
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-512, we bucket by that
|
// If all items are supposed to have a SHA-512, we bucket by that
|
||||||
if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA512))
|
if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA512))
|
||||||
return ItemKey.SHA512;
|
return ItemKey.SHA512;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-384, we bucket by that
|
// If all items are supposed to have a SHA-384, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA384))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA384))
|
||||||
return ItemKey.SHA384;
|
return ItemKey.SHA384;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-256, we bucket by that
|
// If all items are supposed to have a SHA-256, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA256))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA256))
|
||||||
return ItemKey.SHA256;
|
return ItemKey.SHA256;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-1, we bucket by that
|
// If all items are supposed to have a SHA-1, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.SHA1))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.SHA1))
|
||||||
return ItemKey.SHA1;
|
return ItemKey.SHA1;
|
||||||
|
|
||||||
// If all items are supposed to have a MD5, we bucket by that
|
// If all items are supposed to have a MD5, we bucket by that
|
||||||
else if (diskCount + mediaCount + romCount - NodumpCount == GetHashCount(Hash.MD5))
|
else if (diskCount + mediaCount + romCount - nodumpCount == GetHashCount(Hash.MD5))
|
||||||
return ItemKey.MD5;
|
return ItemKey.MD5;
|
||||||
|
|
||||||
// Otherwise, we bucket by CRC
|
// Otherwise, we bucket by CRC
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ body {
|
|||||||
{
|
{
|
||||||
xtw.WriteStartElement("td");
|
xtw.WriteStartElement("td");
|
||||||
xtw.WriteAttributeString("align", "right");
|
xtw.WriteAttributeString("align", "right");
|
||||||
xtw.WriteString(stat.Statistics.BaddumpCount.ToString());
|
xtw.WriteString(stat.Statistics.GetStatusCount(Core.ItemStatus.BadDump).ToString());
|
||||||
xtw.WriteEndElement(); // td
|
xtw.WriteEndElement(); // td
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ body {
|
|||||||
{
|
{
|
||||||
xtw.WriteStartElement("td");
|
xtw.WriteStartElement("td");
|
||||||
xtw.WriteAttributeString("align", "right");
|
xtw.WriteAttributeString("align", "right");
|
||||||
xtw.WriteString(stat.Statistics.NodumpCount.ToString());
|
xtw.WriteString(stat.Statistics.GetStatusCount(Core.ItemStatus.Nodump).ToString());
|
||||||
xtw.WriteEndElement(); // td
|
xtw.WriteEndElement(); // td
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ namespace SabreTools.Reports.Formats
|
|||||||
stat.Statistics.GetHashCount(Core.Hash.SHA256).ToString(),
|
stat.Statistics.GetHashCount(Core.Hash.SHA256).ToString(),
|
||||||
stat.Statistics.GetHashCount(Core.Hash.SHA384).ToString(),
|
stat.Statistics.GetHashCount(Core.Hash.SHA384).ToString(),
|
||||||
stat.Statistics.GetHashCount(Core.Hash.SHA512).ToString(),
|
stat.Statistics.GetHashCount(Core.Hash.SHA512).ToString(),
|
||||||
baddumpCol ? stat.Statistics.BaddumpCount.ToString() : string.Empty,
|
baddumpCol ? stat.Statistics.GetStatusCount(Core.ItemStatus.BadDump).ToString() : string.Empty,
|
||||||
nodumpCol ? stat.Statistics.NodumpCount.ToString() : string.Empty,
|
nodumpCol ? stat.Statistics.GetStatusCount(Core.ItemStatus.Nodump).ToString() : string.Empty,
|
||||||
];
|
];
|
||||||
svw.WriteValues(values);
|
svw.WriteValues(values);
|
||||||
svw.Flush();
|
svw.Flush();
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ namespace SabreTools.Reports.Formats
|
|||||||
Roms with SHA-512: " + stat.Statistics.GetHashCount(Core.Hash.SHA512) + "\n";
|
Roms with SHA-512: " + stat.Statistics.GetHashCount(Core.Hash.SHA512) + "\n";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
line += " Roms with BadDump status: " + stat.Statistics.BaddumpCount + "\n";
|
line += " Roms with BadDump status: " + stat.Statistics.GetStatusCount(Core.ItemStatus.BadDump) + "\n";
|
||||||
|
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
line += " Roms with Nodump status: " + stat.Statistics.NodumpCount + "\n";
|
line += " Roms with Nodump status: " + stat.Statistics.GetStatusCount(Core.ItemStatus.Nodump) + "\n";
|
||||||
|
|
||||||
// For spacing between DATs
|
// For spacing between DATs
|
||||||
line += "\n\n";
|
line += "\n\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user