< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.InternalItemsQuery
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
Line coverage
98%
Covered lines: 64
Uncovered lines: 1
Coverable lines: 65
Total lines: 392
Line coverage: 98.4%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 9/27/2025 - 12:11:20 AM Line coverage: 98.4% (64/65) Branch coverage: 83.3% (5/6) Total lines: 39012/29/2025 - 12:13:19 AM Line coverage: 98.4% (64/65) Branch coverage: 83.3% (5/6) Total lines: 392 9/27/2025 - 12:11:20 AM Line coverage: 98.4% (64/65) Branch coverage: 83.3% (5/6) Total lines: 39012/29/2025 - 12:13:19 AM Line coverage: 98.4% (64/65) Branch coverage: 83.3% (5/6) Total lines: 392

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
.ctor(...)100%22100%
set_Parent(...)100%22100%
SetUser(...)50%2294.11%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/InternalItemsQuery.cs

#LineLine coverage
 1#pragma warning disable CA1044, CA1819, CA2227, CS1591
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Linq;
 6using Diacritics.Extensions;
 7using Jellyfin.Data;
 8using Jellyfin.Data.Enums;
 9using Jellyfin.Database.Implementations.Entities;
 10using Jellyfin.Database.Implementations.Enums;
 11using MediaBrowser.Controller.Dto;
 12using MediaBrowser.Model.Entities;
 13
 14namespace MediaBrowser.Controller.Entities
 15{
 16    public class InternalItemsQuery
 17    {
 18        public InternalItemsQuery()
 19        {
 45220            AlbumArtistIds = Array.Empty<Guid>();
 45221            AlbumIds = Array.Empty<Guid>();
 45222            AncestorIds = Array.Empty<Guid>();
 45223            ArtistIds = Array.Empty<Guid>();
 45224            BlockUnratedItems = Array.Empty<UnratedItem>();
 45225            BoxSetLibraryFolders = Array.Empty<Guid>();
 45226            ChannelIds = Array.Empty<Guid>();
 45227            ContributingArtistIds = Array.Empty<Guid>();
 45228            DtoOptions = new DtoOptions();
 45229            EnableTotalRecordCount = true;
 45230            ExcludeArtistIds = Array.Empty<Guid>();
 45231            ExcludeInheritedTags = Array.Empty<string>();
 45232            IncludeInheritedTags = Array.Empty<string>();
 45233            ExcludeItemIds = Array.Empty<Guid>();
 45234            ExcludeItemTypes = Array.Empty<BaseItemKind>();
 45235            ExcludeTags = Array.Empty<string>();
 45236            GenreIds = Array.Empty<Guid>();
 45237            Genres = Array.Empty<string>();
 45238            GroupByPresentationUniqueKey = true;
 45239            ImageTypes = Array.Empty<ImageType>();
 45240            IncludeItemTypes = Array.Empty<BaseItemKind>();
 45241            ItemIds = Array.Empty<Guid>();
 45242            MediaTypes = Array.Empty<MediaType>();
 45243            OfficialRatings = Array.Empty<string>();
 45244            OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
 45245            PersonIds = Array.Empty<Guid>();
 45246            PersonTypes = Array.Empty<string>();
 45247            PresetViews = Array.Empty<CollectionType?>();
 45248            SeriesStatuses = Array.Empty<SeriesStatus>();
 45249            SourceTypes = Array.Empty<SourceType>();
 45250            StudioIds = Array.Empty<Guid>();
 45251            Tags = Array.Empty<string>();
 45252            TopParentIds = Array.Empty<Guid>();
 45253            TrailerTypes = Array.Empty<TrailerType>();
 45254            VideoTypes = Array.Empty<VideoType>();
 45255            Years = Array.Empty<int>();
 45256            SkipDeserialization = false;
 45257        }
 58
 59        public InternalItemsQuery(User? user)
 260            : this()
 61        {
 262            if (user is not null)
 63            {
 264                SetUser(user);
 65            }
 266        }
 67
 68        public bool Recursive { get; set; }
 69
 70        public int? StartIndex { get; set; }
 71
 72        public int? Limit { get; set; }
 73
 74        public User? User { get; set; }
 75
 76        public bool? IsFolder { get; set; }
 77
 78        public bool? IsFavorite { get; set; }
 79
 80        public bool? IsFavoriteOrLiked { get; set; }
 81
 82        public bool? IsLiked { get; set; }
 83
 84        public bool? IsPlayed { get; set; }
 85
 86        public bool? IsResumable { get; set; }
 87
 88        public bool? IncludeItemsByName { get; set; }
 89
 90        public MediaType[] MediaTypes { get; set; }
 91
 92        public BaseItemKind[] IncludeItemTypes { get; set; }
 93
 94        public BaseItemKind[] ExcludeItemTypes { get; set; }
 95
 96        public string[] ExcludeTags { get; set; }
 97
 98        public string[] ExcludeInheritedTags { get; set; }
 99
 100        public string[] IncludeInheritedTags { get; set; }
 101
 102        public IReadOnlyList<string> Genres { get; set; }
 103
 104        public bool? IsSpecialSeason { get; set; }
 105
 106        public bool? IsMissing { get; set; }
 107
 108        public bool? IsUnaired { get; set; }
 109
 110        public bool? CollapseBoxSetItems { get; set; }
 111
 112        public string? NameStartsWithOrGreater { get; set; }
 113
 114        public string? NameStartsWith { get; set; }
 115
 116        public string? NameLessThan { get; set; }
 117
 118        public string? NameContains { get; set; }
 119
 120        public string? MinSortName { get; set; }
 121
 122        public string? PresentationUniqueKey { get; set; }
 123
 124        public string? Path { get; set; }
 125
 126        public string? Name { get; set; }
 127
 128        public bool? UseRawName { get; set; }
 129
 130        public string? Person { get; set; }
 131
 132        public Guid[] PersonIds { get; set; }
 133
 134        public Guid[] ItemIds { get; set; }
 135
 136        public Guid[] ExcludeItemIds { get; set; }
 137
 138        public Guid? AdjacentTo { get; set; }
 139
 140        public string[] PersonTypes { get; set; }
 141
 142        public bool? Is3D { get; set; }
 143
 144        public bool? IsHD { get; set; }
 145
 146        public bool? IsLocked { get; set; }
 147
 148        public bool? IsPlaceHolder { get; set; }
 149
 150        public bool? HasImdbId { get; set; }
 151
 152        public bool? HasOverview { get; set; }
 153
 154        public bool? HasTmdbId { get; set; }
 155
 156        public bool? HasOfficialRating { get; set; }
 157
 158        public bool? HasTvdbId { get; set; }
 159
 160        public bool? HasThemeSong { get; set; }
 161
 162        public bool? HasThemeVideo { get; set; }
 163
 164        public bool? HasSubtitles { get; set; }
 165
 166        public bool? HasSpecialFeature { get; set; }
 167
 168        public bool? HasTrailer { get; set; }
 169
 170        public bool? HasParentalRating { get; set; }
 171
 172        public Guid[] StudioIds { get; set; }
 173
 174        public IReadOnlyList<Guid> GenreIds { get; set; }
 175
 176        public ImageType[] ImageTypes { get; set; }
 177
 178        public VideoType[] VideoTypes { get; set; }
 179
 180        public UnratedItem[] BlockUnratedItems { get; set; }
 181
 182        public int[] Years { get; set; }
 183
 184        public string[] Tags { get; set; }
 185
 186        public string[] OfficialRatings { get; set; }
 187
 188        public DateTime? MinPremiereDate { get; set; }
 189
 190        public DateTime? MaxPremiereDate { get; set; }
 191
 192        public DateTime? MinStartDate { get; set; }
 193
 194        public DateTime? MaxStartDate { get; set; }
 195
 196        public DateTime? MinEndDate { get; set; }
 197
 198        public DateTime? MaxEndDate { get; set; }
 199
 200        public bool? IsAiring { get; set; }
 201
 202        public bool? IsMovie { get; set; }
 203
 204        public bool? IsSports { get; set; }
 205
 206        public bool? IsKids { get; set; }
 207
 208        public bool? IsNews { get; set; }
 209
 210        public bool? IsSeries { get; set; }
 211
 212        public int? MinIndexNumber { get; set; }
 213
 214        /// <summary>
 215        /// Gets or sets the minimum ParentIndexNumber and IndexNumber.
 216        /// </summary>
 217        /// <remarks>
 218        /// It produces this where clause:
 219        /// <para>(ParentIndexNumber = X and IndexNumber >= Y) or ParentIndexNumber > X.
 220        /// </para>
 221        /// </remarks>
 222        public (int ParentIndexNumber, int IndexNumber)? MinParentAndIndexNumber { get; set; }
 223
 224        public int? AiredDuringSeason { get; set; }
 225
 226        public double? MinCriticRating { get; set; }
 227
 228        public double? MinCommunityRating { get; set; }
 229
 230        public IReadOnlyList<Guid> ChannelIds { get; set; }
 231
 232        public int? ParentIndexNumber { get; set; }
 233
 234        public int? ParentIndexNumberNotEquals { get; set; }
 235
 236        public int? IndexNumber { get; set; }
 237
 238        public ParentalRatingScore? MinParentalRating { get; set; }
 239
 240        public ParentalRatingScore? MaxParentalRating { get; set; }
 241
 242        public bool? HasDeadParentId { get; set; }
 243
 244        public bool? IsVirtualItem { get; set; }
 245
 246        public Guid ParentId { get; set; }
 247
 248        public BaseItemKind? ParentType { get; set; }
 249
 250        public Guid[] AncestorIds { get; set; }
 251
 252        public Guid[] TopParentIds { get; set; }
 253
 254        public CollectionType?[] PresetViews { get; set; }
 255
 256        public TrailerType[] TrailerTypes { get; set; }
 257
 258        public SourceType[] SourceTypes { get; set; }
 259
 260        public SeriesStatus[] SeriesStatuses { get; set; }
 261
 262        public string? ExternalSeriesId { get; set; }
 263
 264        public string? ExternalId { get; set; }
 265
 266        public Guid[] AlbumIds { get; set; }
 267
 268        public Guid[] ArtistIds { get; set; }
 269
 270        public Guid[] ExcludeArtistIds { get; set; }
 271
 272        public string? AncestorWithPresentationUniqueKey { get; set; }
 273
 274        public string? SeriesPresentationUniqueKey { get; set; }
 275
 276        public bool GroupByPresentationUniqueKey { get; set; }
 277
 278        public bool GroupBySeriesPresentationUniqueKey { get; set; }
 279
 280        public bool EnableTotalRecordCount { get; set; }
 281
 282        public bool ForceDirect { get; set; }
 283
 284        public Dictionary<string, string>? ExcludeProviderIds { get; set; }
 285
 286        public bool EnableGroupByMetadataKey { get; set; }
 287
 288        public bool? HasChapterImages { get; set; }
 289
 290        public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
 291
 292        public DateTime? MinDateCreated { get; set; }
 293
 294        public DateTime? MinDateLastSaved { get; set; }
 295
 296        public DateTime? MinDateLastSavedForUser { get; set; }
 297
 298        public DtoOptions DtoOptions { get; set; }
 299
 300        public string? HasNoAudioTrackWithLanguage { get; set; }
 301
 302        public string? HasNoInternalSubtitleTrackWithLanguage { get; set; }
 303
 304        public string? HasNoExternalSubtitleTrackWithLanguage { get; set; }
 305
 306        public string? HasNoSubtitleTrackWithLanguage { get; set; }
 307
 308        public bool? IsDeadArtist { get; set; }
 309
 310        public bool? IsDeadStudio { get; set; }
 311
 312        public bool? IsDeadGenre { get; set; }
 313
 314        public bool? IsDeadPerson { get; set; }
 315
 316        /// <summary>
 317        /// Gets or sets a value indicating whether album sub-folders should be returned if they exist.
 318        /// </summary>
 319        public bool? DisplayAlbumFolders { get; set; }
 320
 321        public BaseItem? Parent
 322        {
 323            set
 324            {
 261325                if (value is null)
 326                {
 58327                    ParentId = Guid.Empty;
 58328                    ParentType = null;
 329                }
 330                else
 331                {
 203332                    ParentId = value.Id;
 203333                    ParentType = value.GetBaseItemKind();
 334                }
 203335            }
 336        }
 337
 338        public Dictionary<string, string>? HasAnyProviderId { get; set; }
 339
 340        public Guid[] AlbumArtistIds { get; set; }
 341
 342        public Guid[] BoxSetLibraryFolders { get; set; }
 343
 344        public Guid[] ContributingArtistIds { get; set; }
 345
 346        public bool? HasAired { get; set; }
 347
 348        public bool? HasOwnerId { get; set; }
 349
 350        public bool? Is4K { get; set; }
 351
 352        public int? MaxHeight { get; set; }
 353
 354        public int? MaxWidth { get; set; }
 355
 356        public int? MinHeight { get; set; }
 357
 358        public int? MinWidth { get; set; }
 359
 360        public string? SearchTerm { get; set; }
 361
 362        public string? SeriesTimerId { get; set; }
 363
 364        public bool SkipDeserialization { get; set; }
 365
 366        public void SetUser(User user)
 367        {
 2368            var maxRating = user.MaxParentalRatingScore;
 2369            if (maxRating.HasValue)
 370            {
 0371                MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore);
 372            }
 373
 2374            var other = UnratedItem.Other.ToString();
 2375            BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
 2376                .Where(i => i != other)
 2377                .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
 378
 2379            ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags)
 2380                .Where(tag => !string.IsNullOrWhiteSpace(tag))
 2381                .Select(tag => tag.RemoveDiacritics().ToLowerInvariant())
 2382                .ToArray();
 383
 2384            IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags)
 2385                .Where(tag => !string.IsNullOrWhiteSpace(tag))
 2386                .Select(tag => tag.RemoveDiacritics().ToLowerInvariant())
 2387                .ToArray();
 388
 2389            User = user;
 2390        }
 391    }
 392}