Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/jellyfin/commit/2955f2f56275fca01cd3f586b3475dcdfbea78ed You should set ROOT_URL correctly, otherwise the web may not work correctly.

Fixed AncestorIds and applied review comments

pull/12798/head
JPVenson 5 months ago
parent eb601e944c
commit 2955f2f562

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using Jellyfin.Api.Extensions;
@ -120,7 +121,7 @@ public class MoviesController : BaseJellyfinApiController
DtoOptions = dtoOptions
});
var mostRecentMovies = recentlyPlayedMovies.Take(Math.Min(recentlyPlayedMovies.Count, 6));
var mostRecentMovies = recentlyPlayedMovies.Take(Math.Min(recentlyPlayedMovies.Count, 6)).ToImmutableList();
// Get recently played directors
var recentDirectors = GetDirectors(mostRecentMovies)
.ToList();

@ -1,19 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Jellyfin.Data.Entities;
#pragma warning disable CA1708 // Identifiers should differ by more than case
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
/// <summary>
/// Represents the relational informations for an <see cref="BaseItemEntity"/>.
/// </summary>
public class AncestorId
{
public Guid Id { get; set; }
/// <summary>
/// Gets or Sets the AncestorId that may or may not be an database managed Item or an materialised local item.
/// </summary>
public required Guid ParentItemId { get; set; }
/// <summary>
/// Gets or Sets the related that may or may not be an database managed Item or an materialised local item.
/// </summary>
public required Guid ItemId { get; set; }
public required BaseItemEntity Item { get; set; }
public string? AncestorIdText { get; set; }
}

@ -12,7 +12,7 @@ public class MediaStreamInfo
public int StreamIndex { get; set; }
public string? StreamType { get; set; }
public MediaStreamTypeEntity? StreamType { get; set; }
public string? Codec { get; set; }

@ -0,0 +1,37 @@
namespace Jellyfin.Data.Entities;
/// <summary>
/// Enum MediaStreamType.
/// </summary>
public enum MediaStreamTypeEntity
{
/// <summary>
/// The audio.
/// </summary>
Audio,
/// <summary>
/// The video.
/// </summary>
Video,
/// <summary>
/// The subtitle.
/// </summary>
Subtitle,
/// <summary>
/// The embedded image.
/// </summary>
EmbeddedImage,
/// <summary>
/// The data.
/// </summary>
Data,
/// <summary>
/// The lyric.
/// </summary>
Lyric
}

@ -1,133 +0,0 @@
namespace Jellyfin.Data.Entities;
/// <summary>
/// The person kind.
/// </summary>
public enum PeopleKind
{
/// <summary>
/// An unknown person kind.
/// </summary>
Unknown,
/// <summary>
/// A person whose profession is acting on the stage, in films, or on television.
/// </summary>
Actor,
/// <summary>
/// A person who supervises the actors and other staff in a film, play, or similar production.
/// </summary>
Director,
/// <summary>
/// A person who writes music, especially as a professional occupation.
/// </summary>
Composer,
/// <summary>
/// A writer of a book, article, or document. Can also be used as a generic term for music writer if there is a lack of specificity.
/// </summary>
Writer,
/// <summary>
/// A well-known actor or other performer who appears in a work in which they do not have a regular role.
/// </summary>
GuestStar,
/// <summary>
/// A person responsible for the financial and managerial aspects of the making of a film or broadcast or for staging a play, opera, etc.
/// </summary>
Producer,
/// <summary>
/// A person who directs the performance of an orchestra or choir.
/// </summary>
Conductor,
/// <summary>
/// A person who writes the words to a song or musical.
/// </summary>
Lyricist,
/// <summary>
/// A person who adapts a musical composition for performance.
/// </summary>
Arranger,
/// <summary>
/// An audio engineer who performed a general engineering role.
/// </summary>
Engineer,
/// <summary>
/// An engineer responsible for using a mixing console to mix a recorded track into a single piece of music suitable for release.
/// </summary>
Mixer,
/// <summary>
/// A person who remixed a recording by taking one or more other tracks, substantially altering them and mixing them together with other material.
/// </summary>
Remixer,
/// <summary>
/// A person who created the material.
/// </summary>
Creator,
/// <summary>
/// A person who was the artist.
/// </summary>
Artist,
/// <summary>
/// A person who was the album artist.
/// </summary>
AlbumArtist,
/// <summary>
/// A person who was the author.
/// </summary>
Author,
/// <summary>
/// A person who was the illustrator.
/// </summary>
Illustrator,
/// <summary>
/// A person responsible for drawing the art.
/// </summary>
Penciller,
/// <summary>
/// A person responsible for inking the pencil art.
/// </summary>
Inker,
/// <summary>
/// A person responsible for applying color to drawings.
/// </summary>
Colorist,
/// <summary>
/// A person responsible for drawing text and speech bubbles.
/// </summary>
Letterer,
/// <summary>
/// A person responsible for drawing the cover art.
/// </summary>
CoverArtist,
/// <summary>
/// A person contributing to a resource by revising or elucidating the content, e.g., adding an introduction, notes, or other critical matter.
/// An editor may also prepare a resource for production, publication, or distribution.
/// </summary>
Editor,
/// <summary>
/// A person who renders a text from one language into another.
/// </summary>
Translator
}

@ -83,7 +83,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
using var transaction = context.Database.BeginTransaction();
context.ItemValues.Where(e => e.Type == 6).ExecuteDelete();
context.ItemValues.AddRange(context.ItemValues.Where(e => e.Type == 4).Select(e => new Data.Entities.ItemValue()
context.ItemValues.AddRange(context.ItemValues.Where(e => e.Type == 4).Select(e => new ItemValue()
{
CleanValue = e.CleanValue,
ItemId = e.ItemId,
@ -93,7 +93,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
}));
context.ItemValues.AddRange(
context.AncestorIds.Where(e => e.AncestorIdText != null).Join(context.ItemValues.Where(e => e.Value != null && e.Type == 4), e => e.Id, e => e.ItemId, (e, f) => new Data.Entities.ItemValue()
context.AncestorIds.Join(context.ItemValues.Where(e => e.Value != null && e.Type == 4), e => e.ParentItemId, e => e.ItemId, (e, f) => new ItemValue()
{
CleanValue = f.CleanValue,
ItemId = e.ItemId,
@ -893,31 +893,31 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
if (!string.IsNullOrWhiteSpace(filter.HasNoAudioTrackWithLanguage))
{
baseQuery = baseQuery
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == "Audio" && e.Language == filter.HasNoAudioTrackWithLanguage));
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == MediaStreamTypeEntity.Audio && e.Language == filter.HasNoAudioTrackWithLanguage));
}
if (!string.IsNullOrWhiteSpace(filter.HasNoInternalSubtitleTrackWithLanguage))
{
baseQuery = baseQuery
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == "Subtitle" && !e.IsExternal && e.Language == filter.HasNoInternalSubtitleTrackWithLanguage));
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == MediaStreamTypeEntity.Subtitle && !e.IsExternal && e.Language == filter.HasNoInternalSubtitleTrackWithLanguage));
}
if (!string.IsNullOrWhiteSpace(filter.HasNoExternalSubtitleTrackWithLanguage))
{
baseQuery = baseQuery
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == "Subtitle" && e.IsExternal && e.Language == filter.HasNoExternalSubtitleTrackWithLanguage));
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == MediaStreamTypeEntity.Subtitle && e.IsExternal && e.Language == filter.HasNoExternalSubtitleTrackWithLanguage));
}
if (!string.IsNullOrWhiteSpace(filter.HasNoSubtitleTrackWithLanguage))
{
baseQuery = baseQuery
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == "Subtitle" && e.Language == filter.HasNoSubtitleTrackWithLanguage));
.Where(e => !e.MediaStreams!.Any(e => e.StreamType == MediaStreamTypeEntity.Subtitle && e.Language == filter.HasNoSubtitleTrackWithLanguage));
}
if (filter.HasSubtitles.HasValue)
{
baseQuery = baseQuery
.Where(e => e.MediaStreams!.Any(e => e.StreamType == "Subtitle") == filter.HasSubtitles.Value);
.Where(e => e.MediaStreams!.Any(e => e.StreamType == MediaStreamTypeEntity.Subtitle) == filter.HasSubtitles.Value);
}
if (filter.HasChapterImages.HasValue)
@ -1062,7 +1062,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
if (filter.AncestorIds.Length > 0)
{
baseQuery = baseQuery.Where(e => e.AncestorIds!.Any(f => filter.AncestorIds.Contains(f.Id)));
baseQuery = baseQuery.Where(e => e.AncestorIds!.Any(f => filter.AncestorIds.Contains(f.ParentItemId)));
}
if (!string.IsNullOrWhiteSpace(filter.AncestorWithPresentationUniqueKey))
@ -1273,9 +1273,7 @@ public sealed class BaseItemRepository(IDbContextFactory<JellyfinDbContext> dbPr
{
entity.AncestorIds.Add(new AncestorId()
{
Item = entity,
AncestorIdText = ancestorId.ToString(),
Id = ancestorId,
ParentItemId = ancestorId,
ItemId = entity.Id
});
}

@ -40,7 +40,7 @@ public class MediaAttachmentRepository(IDbContextFactory<JellyfinDbContext> dbPr
query = query.Where(e => e.Index == filter.Index);
}
return query.ToList().Select(Map).ToImmutableArray();
return query.AsEnumerable().Select(Map).ToImmutableArray();
}
private MediaAttachment Map(AttachmentStreamInfo attachment)

@ -70,7 +70,8 @@ public class MediaStreamRepository(IDbContextFactory<JellyfinDbContext> dbProvid
if (filter.Type.HasValue)
{
query = query.Where(e => e.StreamType == filter.Type.ToString());
var typeValue = (MediaStreamTypeEntity)filter.Type.Value;
query = query.Where(e => e.StreamType!.Value == typeValue);
}
return query;
@ -82,7 +83,7 @@ public class MediaStreamRepository(IDbContextFactory<JellyfinDbContext> dbProvid
dto.Index = entity.StreamIndex;
if (entity.StreamType != null)
{
dto.Type = Enum.Parse<MediaStreamType>(entity.StreamType);
dto.Type = (MediaStreamType)entity.StreamType;
}
dto.IsAVC = entity.IsAvc;
@ -151,7 +152,7 @@ public class MediaStreamRepository(IDbContextFactory<JellyfinDbContext> dbProvid
Item = null!,
ItemId = itemId,
StreamIndex = dto.Index,
StreamType = dto.Type.ToString(),
StreamType = (MediaStreamTypeEntity)dto.Type,
IsAvc = dto.IsAVC.GetValueOrDefault(),
Codec = dto.Codec,

@ -34,7 +34,7 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider) :
dbQuery = dbQuery.Take(filter.Limit);
}
return dbQuery.ToList().Select(Map).ToImmutableArray();
return dbQuery.AsEnumerable().Select(Map).ToImmutableArray();
}
/// <inheritdoc/>

@ -0,0 +1,89 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Server.Implementations.Migrations
{
/// <inheritdoc />
public partial class FixedAncestorIds : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AncestorIds_BaseItems_ItemId",
table: "AncestorIds");
migrationBuilder.DropIndex(
name: "IX_AncestorIds_ItemId_AncestorIdText",
table: "AncestorIds");
migrationBuilder.RenameColumn(
name: "AncestorIdText",
table: "AncestorIds",
newName: "BaseItemEntityId");
migrationBuilder.RenameColumn(
name: "Id",
table: "AncestorIds",
newName: "ParentItemId");
migrationBuilder.RenameIndex(
name: "IX_AncestorIds_Id",
table: "AncestorIds",
newName: "IX_AncestorIds_ParentItemId");
migrationBuilder.CreateIndex(
name: "IX_AncestorIds_BaseItemEntityId",
table: "AncestorIds",
column: "BaseItemEntityId");
migrationBuilder.AddForeignKey(
name: "FK_AncestorIds_BaseItems_BaseItemEntityId",
table: "AncestorIds",
column: "BaseItemEntityId",
principalTable: "BaseItems",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AncestorIds_BaseItems_BaseItemEntityId",
table: "AncestorIds");
migrationBuilder.DropIndex(
name: "IX_AncestorIds_BaseItemEntityId",
table: "AncestorIds");
migrationBuilder.RenameColumn(
name: "BaseItemEntityId",
table: "AncestorIds",
newName: "AncestorIdText");
migrationBuilder.RenameColumn(
name: "ParentItemId",
table: "AncestorIds",
newName: "Id");
migrationBuilder.RenameIndex(
name: "IX_AncestorIds_ParentItemId",
table: "AncestorIds",
newName: "IX_AncestorIds_Id");
migrationBuilder.CreateIndex(
name: "IX_AncestorIds_ItemId_AncestorIdText",
table: "AncestorIds",
columns: new[] { "ItemId", "AncestorIdText" });
migrationBuilder.AddForeignKey(
name: "FK_AncestorIds_BaseItems_ItemId",
table: "AncestorIds",
column: "ItemId",
principalTable: "BaseItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Server.Implementations.Migrations
{
/// <inheritdoc />
public partial class FixedStreamType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "StreamType",
table: "MediaStreamInfos",
type: "INTEGER",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "StreamType",
table: "MediaStreamInfos",
type: "TEXT",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
}
}
}

@ -95,17 +95,17 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<Guid>("ItemId")
.HasColumnType("TEXT");
b.Property<Guid>("Id")
b.Property<Guid>("ParentItemId")
.HasColumnType("TEXT");
b.Property<string>("AncestorIdText")
b.Property<Guid?>("BaseItemEntityId")
.HasColumnType("TEXT");
b.HasKey("ItemId", "Id");
b.HasKey("ItemId", "ParentItemId");
b.HasIndex("Id");
b.HasIndex("BaseItemEntityId");
b.HasIndex("ItemId", "AncestorIdText");
b.HasIndex("ParentItemId");
b.ToTable("AncestorIds");
});
@ -865,8 +865,8 @@ namespace Jellyfin.Server.Implementations.Migrations
b.Property<int>("SampleRate")
.HasColumnType("INTEGER");
b.Property<string>("StreamType")
.HasColumnType("TEXT");
b.Property<int?>("StreamType")
.HasColumnType("INTEGER");
b.Property<string>("TimeBase")
.IsRequired()
@ -1304,13 +1304,9 @@ namespace Jellyfin.Server.Implementations.Migrations
modelBuilder.Entity("Jellyfin.Data.Entities.AncestorId", b =>
{
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", "Item")
b.HasOne("Jellyfin.Data.Entities.BaseItemEntity", null)
.WithMany("AncestorIds")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
.HasForeignKey("BaseItemEntityId");
});
modelBuilder.Entity("Jellyfin.Data.Entities.AttachmentStreamInfo", b =>

@ -13,8 +13,7 @@ public class AncestorIdConfiguration : IEntityTypeConfiguration<AncestorId>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<AncestorId> builder)
{
builder.HasKey(e => new { e.ItemId, e.Id });
builder.HasIndex(e => e.Id);
builder.HasIndex(e => new { e.ItemId, e.AncestorIdText });
builder.HasKey(e => new { e.ItemId, e.ParentItemId });
builder.HasIndex(e => e.ParentItemId);
}
}

@ -184,10 +184,8 @@ public class MigrateLibraryDb : IMigrationRoutine
{
return new AncestorId()
{
Item = null!,
ItemId = reader.GetGuid(0),
Id = reader.GetGuid(1),
AncestorIdText = reader.GetString(2)
ParentItemId = reader.GetGuid(1)
};
}
@ -273,7 +271,7 @@ public class MigrateLibraryDb : IMigrationRoutine
var item = new MediaStreamInfo
{
StreamIndex = reader.GetInt32(1),
StreamType = reader.GetString(2),
StreamType = Enum.Parse<MediaStreamTypeEntity>(reader.GetString(2)),
Item = null!,
ItemId = reader.GetGuid(0),
AverageFrameRate = 0,

Loading…
Cancel
Save