jellyfin/MediaBrowser.Controller/Persistence/ILinkedChildrenService.cs
brandon 10d108a1f4 Address review on MediaSourceCount batching
Rename GetItemsWithAlternateVersions to GetItemIdsWithAlternateVersions
across the interfaces and implementations since it returns ids. Return
the hashset straight from the query instead of materializing an array
first. Rename the DtoService guard to mayHaveAlternateVersions and
invert it so the computed path is the explicit case. Assert the media
source count value in the batch skip test and add a test covering an
item that is in the returned set still resolving to the correct count.
2026-08-08 12:33:11 -04:00

61 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities.Audio;
using LinkedChildType = MediaBrowser.Controller.Entities.LinkedChildType;
namespace MediaBrowser.Controller.Persistence;
/// <summary>
/// Provides linked children query and manipulation operations.
/// </summary>
public interface ILinkedChildrenService
{
/// <summary>
/// Gets the IDs of linked children for the specified parent.
/// </summary>
/// <param name="parentId">The parent item ID.</param>
/// <param name="childType">Optional child type filter.</param>
/// <returns>List of child item IDs.</returns>
IReadOnlyList<Guid> GetLinkedChildrenIds(Guid parentId, int? childType = null);
/// <summary>
/// Gets, in a single query, the subset of the supplied items that own at least one alternate
/// version (local or linked). Items absent from the result have no alternate versions, so their
/// media source count is one.
/// </summary>
/// <param name="itemIds">The item IDs to check.</param>
/// <returns>The set of item IDs that have alternate versions.</returns>
IReadOnlySet<Guid> GetItemIdsWithAlternateVersions(IReadOnlyList<Guid> itemIds);
/// <summary>
/// Gets all artist matches from the database.
/// </summary>
/// <param name="artistNames">The names of the artists.</param>
/// <returns>A map of the artist name and the potential matches.</returns>
IReadOnlyDictionary<string, MusicArtist[]> FindArtists(IReadOnlyList<string> artistNames);
/// <summary>
/// Gets parent IDs that reference the specified child with LinkedChildType.Manual.
/// </summary>
/// <param name="childId">The child item ID.</param>
/// <param name="parentType">Optional parent item type filter.</param>
/// <returns>List of parent IDs that reference the child.</returns>
IReadOnlyList<Guid> GetManualLinkedParentIds(Guid childId, BaseItemKind? parentType = null);
/// <summary>
/// Updates LinkedChildren references from one child to another.
/// </summary>
/// <param name="fromChildId">The child ID to re-route from.</param>
/// <param name="toChildId">The child ID to re-route to.</param>
/// <returns>List of parent item IDs whose LinkedChildren were modified.</returns>
IReadOnlyList<Guid> RerouteLinkedChildren(Guid fromChildId, Guid toChildId);
/// <summary>
/// Creates or updates a LinkedChild entry.
/// </summary>
/// <param name="parentId">The parent item ID.</param>
/// <param name="childId">The child item ID.</param>
/// <param name="childType">The type of linked child relationship.</param>
void UpsertLinkedChild(Guid parentId, Guid childId, LinkedChildType childType);
}