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

@@ -15,6 +15,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
[ExcludeFromCodeCoverage]
public class LibraryDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="LibraryDto"/> instance with randomized test data.
/// </summary>
@@ -26,16 +28,15 @@ public class LibraryDtoFixture
/// <returns>A configured <see cref="LibraryDto"/> instance.</returns>
public LibraryDto Create(Guid? id = null, string? title = null, string? libraryType = null, bool? isEnabled = null, List<string>? contentLocations = null)
{
Faker faker = new();
return new LibraryDto
{
Id = id ?? Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = title ?? faker.Commerce.Department(),
LibraryType = libraryType ?? faker.PickRandom("Book", "Video", "Photo"),
CoverImage = faker.Image.PicsumUrl(),
ContentLocations = contentLocations ?? [faker.System.DirectoryPath()],
IsEnabled = isEnabled ?? faker.Random.Bool()
Title = title ?? _faker.Commerce.Department(),
LibraryType = libraryType ?? _faker.PickRandom("Book", "Video", "Photo"),
CoverImage = _faker.Image.PicsumUrl(),
ContentLocations = contentLocations ?? [_faker.System.DirectoryPath()],
IsEnabled = isEnabled ?? _faker.Random.Bool()
};
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
/// <summary>
/// Fixture class for generating <see cref="ScanLibraryDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScanLibraryDtoFixture
{
/// <summary>
/// Creates a new <see cref="ScanLibraryDto"/> instance with randomized test data.
/// </summary>
/// <param name="scanId">Optional Id of the media library scan.</param>
/// <param name="libraryId">Optional Id of the scanned media library.</param>
/// <returns>A configured <see cref="ScanLibraryDto"/> instance.</returns>
public ScanLibraryDto Create(
Guid? scanId = null,
Guid? libraryId = null)
{
return new ScanLibraryDto
{
ScanId = scanId ?? Guid.NewGuid(),
LibraryId = libraryId ?? Guid.NewGuid()
};
}
/// <summary>
/// Creates multiple <see cref="ScanLibraryDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ScanLibraryDto"/> instances.</returns>
public List<ScanLibraryDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -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())];
}
}
@@ -15,23 +15,34 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.UsersManagement;
[ExcludeFromCodeCoverage]
public class UserSettingsDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="UserSettingsDto"/> instance with randomized test data.
/// </summary>
/// <param name="userId">Optional identifier of the user that owns the settings.</param>
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user.</param>
/// <param name="itemsPerPage">Number of library items displayed per page.</param>
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
/// <returns>A configured <see cref="UserSettingsDto"/> instance.</returns>
public UserSettingsDto Create(Guid? userId = null, bool? isPaginationEnabled = null, int? itemsPerPage = null, bool? ignoreThePrefixForAlphaPicker = null)
public UserSettingsDto Create(
Guid? userId = null,
bool? isPaginationEnabled = null,
int? itemsPerPage = null,
bool? shouldIgnoreThePrefixForAlphaPicker = null,
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null)
{
Faker faker = new();
return new UserSettingsDto
{
UserId = userId ?? Guid.NewGuid(),
IsPaginationEnabled = isPaginationEnabled ?? faker.Random.Bool(),
ItemsPerPage = itemsPerPage ?? faker.Random.Int(1, 200),
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker ?? faker.Random.Bool()
IsPaginationEnabled = isPaginationEnabled ?? _faker.Random.Bool(),
ItemsPerPage = itemsPerPage ?? _faker.Random.Int(1, 200),
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
IsThemeCachingEnabled = isThemeCachingEnabled ?? _faker.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool()
};
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Requests.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
/// <summary>
/// Fixture class for generating <see cref="ReorderLibraryMetadataProvidersRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class ReorderLibraryMetadataProvidersRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="ReorderLibraryMetadataProvidersRequest"/> instance with randomized test data.
/// </summary>
/// <param name="libraryId">Optional identifier of the media library.</param>
/// <param name="pluginIds">Optional plugin Ids in the new order.</param>
/// <returns>A configured <see cref="ReorderLibraryMetadataProvidersRequest"/> instance.</returns>
public ReorderLibraryMetadataProvidersRequest Create(
Guid? libraryId = null,
List<Guid>? pluginIds = null)
{
return new ReorderLibraryMetadataProvidersRequest
{
LibraryId = libraryId ?? Guid.NewGuid(),
PluginIds = pluginIds ?? [_faker.Random.Guid(), _faker.Random.Guid()]
};
}
/// <summary>
/// Creates multiple <see cref="ReorderLibraryMetadataProvidersRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ReorderLibraryMetadataProvidersRequest"/> instances.</returns>
public List<ReorderLibraryMetadataProvidersRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.Requests.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
/// <summary>
/// Fixture class for generating <see cref="SetLibraryMetadataProviderEnabledRequest"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
public class SetLibraryMetadataProviderEnabledRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="SetLibraryMetadataProviderEnabledRequest"/> instance with randomized test data.
/// </summary>
/// <param name="libraryId">Optional identifier of the media library.</param>
/// <param name="pluginId">Optional identifier of the plugin.</param>
/// <param name="isEnabled">Optional value indicating whether the metadata provider is enabled.</param>
/// <returns>A configured <see cref="SetLibraryMetadataProviderEnabledRequest"/> instance.</returns>
public SetLibraryMetadataProviderEnabledRequest Create(
Guid? libraryId = null,
Guid? pluginId = null,
bool? isEnabled = null)
{
return new SetLibraryMetadataProviderEnabledRequest
{
LibraryId = libraryId ?? Guid.NewGuid(),
PluginId = pluginId ?? Guid.NewGuid(),
IsEnabled = isEnabled ?? _faker.Random.Bool()
};
}
/// <summary>
/// Creates multiple <see cref="SetLibraryMetadataProviderEnabledRequest"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="SetLibraryMetadataProviderEnabledRequest"/> instances.</returns>
public List<SetLibraryMetadataProviderEnabledRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -15,19 +15,22 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
[ExcludeFromCodeCoverage]
public class UpdatePluginSettingsRequestFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="UpdatePluginSettingsRequest"/> instance with randomized test data.
/// </summary>
/// <param name="pluginId">Optional identifier of the plugin.</param>
/// <param name="settings">Optional dictionary of settings.</param>
/// <returns>A configured <see cref="UpdatePluginSettingsRequest"/> instance.</returns>
public UpdatePluginSettingsRequest Create(Guid? pluginId = null, Dictionary<string, string>? settings = null)
public UpdatePluginSettingsRequest Create(
Guid? pluginId = null,
Dictionary<string, string>? settings = null)
{
Faker faker = new();
return new UpdatePluginSettingsRequest
{
PluginId = pluginId ?? Guid.NewGuid(),
Settings = settings ?? new Dictionary<string, string> { [faker.Lorem.Word()] = faker.Lorem.Word() }
Settings = settings ?? new Dictionary<string, string> { [_faker.Lorem.Word()] = _faker.Lorem.Word() }
};
}