Adds metadata aggregation to the media library enrichment job

This commit is contained in:
BinaryAlley committed 2026-08-24 14:18:40 -07:00
1 parent c82fadc7a2
commit 66871ccf62
168 files changed
+3503 -1062

No files matched your search

@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
/// <summary>
/// Fixture class for generating <see cref="LibraryMetadataProviderDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryMetadataProviderDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="LibraryMetadataProviderDto"/> instance with randomized test data.
/// </summary>
/// <param name="pluginId">Optional unique identifier of the plugin providing the metadata.</param>
/// <param name="name">Optional display name of the metadata provider.</param>
/// <param name="isEnabled">Whether the metadata provider is enabled for the media library or not.</param>
/// <param name="rank">Optional rank of the metadata provider, determining the order in which providers are tried.</param>
/// <returns>A configured <see cref="LibraryMetadataProviderDto"/> instance.</returns>
public LibraryMetadataProviderDto Create(
Guid? pluginId = null,
string? name = null,
bool? isEnabled = null,
int? rank = null)
{
return new LibraryMetadataProviderDto
{
PluginId = pluginId ?? Guid.NewGuid(),
Name = name ?? _faker.Company.CompanyName(),
IsEnabled = isEnabled ?? _faker.Random.Bool(),
Rank = rank ?? _faker.Random.Int(0, 100)
};
}
/// <summary>
/// Creates multiple <see cref="LibraryMetadataProviderDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryMetadataProviderDto"/> instances.</returns>
public List<LibraryMetadataProviderDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Plugins;
using Lumina.Presentation.Web.Common.Enums.Plugins;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginSettingDescriptorDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingDescriptorDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PluginSettingDescriptorDto"/>.
/// </summary>
/// <param name="key">Optional. The key of the setting.</param>
/// <param name="label">Optional. The display label of the setting.</param>
/// <param name="type">Optional. The type of the setting.</param>
/// <param name="defaultValue">Optional. The default value of the setting.</param>
/// <param name="allowedValues">Optional. The list of allowed values of the setting.</param>
/// <returns>The created <see cref="PluginSettingDescriptorDto"/>.</returns>
public PluginSettingDescriptorDto Create(
string? key = null,
string? label = null,
PluginSettingType? type = null,
string? defaultValue = null,
IReadOnlyList<string>? allowedValues = null)
{
return new PluginSettingDescriptorDto
{
Key = key ?? _faker.Random.String2(4, 32),
Label = label ?? _faker.Commerce.ProductName(),
Type = type ?? _faker.Random.Enum<PluginSettingType>(),
DefaultValue = defaultValue,
AllowedValues = allowedValues
};
}
/// <summary>
/// Creates a list of <see cref="PluginSettingDescriptorDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginSettingDescriptorDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
/// <summary>
/// Fixture class for generating <see cref="PluginSettingsDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingsDtoFixture
{
private readonly Faker _faker = new();
private readonly PluginSettingDescriptorDtoFixture _pluginSettingDescriptorDtoFixture = new();
/// <summary>
/// Creates a new <see cref="PluginSettingsDto"/> instance with randomized test data.
/// </summary>
/// <param name="pluginId">Optional unique identifier of the plugin.</param>
/// <param name="includeSettings">Whether to populate the current settings values, or leave them null.</param>
/// <param name="includeSchema">Whether to populate the settings schema, or leave it empty.</param>
/// <returns>A configured <see cref="PluginSettingsDto"/> instance.</returns>
public PluginSettingsDto Create(
Guid? pluginId = null,
bool includeSettings = true,
bool includeSchema = true)
{
string settingKey = _faker.Lorem.Word();
return new PluginSettingsDto
{
PluginId = pluginId ?? Guid.NewGuid(),
Schema = includeSchema
? [_pluginSettingDescriptorDtoFixture.Create(key: settingKey)]
: [],
Settings = includeSettings
? new Dictionary<string, string> { [settingKey] = _faker.Lorem.Word() }
: null
};
}
/// <summary>
/// Creates multiple <see cref="PluginSettingsDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PluginSettingsDto"/> instances.</returns>
public List<PluginSettingsDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}