< 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: 390
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

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        {
 50920            AlbumArtistIds = Array.Empty<Guid>();
 50921            AlbumIds = Array.Empty<Guid>();
 50922            AncestorIds = Array.Empty<Guid>();
 50923            ArtistIds = Array.Empty<Guid>();
 50924            BlockUnratedItems = Array.Empty<UnratedItem>();
 50925            BoxSetLibraryFolders = Array.Empty<Guid>();
 50926            ChannelIds = Array.Empty<Guid>();
 50927            ContributingArtistIds = Array.Empty<Guid>();
 50928            DtoOptions = new DtoOptions();
 50929            EnableTotalRecordCount = true;
 50930            ExcludeArtistIds = Array.Empty<Guid>();
 50931            ExcludeInheritedTags = Array.Empty<string>();
 50932            IncludeInheritedTags = Array.Empty<string>();
 50933            ExcludeItemIds = Array.Empty<Guid>();
 50934            ExcludeItemTypes = Array.Empty<BaseItemKind>();
 50935            ExcludeTags = Array.Empty<string>();
 50936            GenreIds = Array.Empty<Guid>();
 50937            Genres = Array.Empty<string>();
 50938            GroupByPresentationUniqueKey = true;
 50939            ImageTypes = Array.Empty<ImageType>();
 50940            IncludeItemTypes = Array.Empty<BaseItemKind>();
 50941            ItemIds = Array.Empty<Guid>();
 50942            MediaTypes = Array.Empty<MediaType>();
 50943            OfficialRatings = Array.Empty<string>();
 50944            OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
 50945            PersonIds = Array.Empty<Guid>();
 50946            PersonTypes = Array.Empty<string>();
 50947            PresetViews = Array.Empty<CollectionType?>();
 50948            SeriesStatuses = Array.Empty<SeriesStatus>();
 50949            SourceTypes = Array.Empty<SourceType>();
 50950            StudioIds = Array.Empty<Guid>();
 50951            Tags = Array.Empty<string>();
 50952            TopParentIds = Array.Empty<Guid>();
 50953            TrailerTypes = Array.Empty<TrailerType>();
 50954            VideoTypes = Array.Empty<VideoType>();
 50955            Years = Array.Empty<int>();
 50956            SkipDeserialization = false;
 50957        }
 58
 59        public InternalItemsQuery(User? user)
 1260            : this()
 61        {
 1262            if (user is not null)
 63            {
 1264                SetUser(user);
 65            }
 1266        }
 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 string? Person { get; set; }
 129
 130        public Guid[] PersonIds { get; set; }
 131
 132        public Guid[] ItemIds { get; set; }
 133
 134        public Guid[] ExcludeItemIds { get; set; }
 135
 136        public Guid? AdjacentTo { get; set; }
 137
 138        public string[] PersonTypes { get; set; }
 139
 140        public bool? Is3D { get; set; }
 141
 142        public bool? IsHD { get; set; }
 143
 144        public bool? IsLocked { get; set; }
 145
 146        public bool? IsPlaceHolder { get; set; }
 147
 148        public bool? HasImdbId { get; set; }
 149
 150        public bool? HasOverview { get; set; }
 151
 152        public bool? HasTmdbId { get; set; }
 153
 154        public bool? HasOfficialRating { get; set; }
 155
 156        public bool? HasTvdbId { get; set; }
 157
 158        public bool? HasThemeSong { get; set; }
 159
 160        public bool? HasThemeVideo { get; set; }
 161
 162        public bool? HasSubtitles { get; set; }
 163
 164        public bool? HasSpecialFeature { get; set; }
 165
 166        public bool? HasTrailer { get; set; }
 167
 168        public bool? HasParentalRating { get; set; }
 169
 170        public Guid[] StudioIds { get; set; }
 171
 172        public IReadOnlyList<Guid> GenreIds { get; set; }
 173
 174        public ImageType[] ImageTypes { get; set; }
 175
 176        public VideoType[] VideoTypes { get; set; }
 177
 178        public UnratedItem[] BlockUnratedItems { get; set; }
 179
 180        public int[] Years { get; set; }
 181
 182        public string[] Tags { get; set; }
 183
 184        public string[] OfficialRatings { get; set; }
 185
 186        public DateTime? MinPremiereDate { get; set; }
 187
 188        public DateTime? MaxPremiereDate { get; set; }
 189
 190        public DateTime? MinStartDate { get; set; }
 191
 192        public DateTime? MaxStartDate { get; set; }
 193
 194        public DateTime? MinEndDate { get; set; }
 195
 196        public DateTime? MaxEndDate { get; set; }
 197
 198        public bool? IsAiring { get; set; }
 199
 200        public bool? IsMovie { get; set; }
 201
 202        public bool? IsSports { get; set; }
 203
 204        public bool? IsKids { get; set; }
 205
 206        public bool? IsNews { get; set; }
 207
 208        public bool? IsSeries { get; set; }
 209
 210        public int? MinIndexNumber { get; set; }
 211
 212        /// <summary>
 213        /// Gets or sets the minimum ParentIndexNumber and IndexNumber.
 214        /// </summary>
 215        /// <remarks>
 216        /// It produces this where clause:
 217        /// <para>(ParentIndexNumber = X and IndexNumber >= Y) or ParentIndexNumber > X.
 218        /// </para>
 219        /// </remarks>
 220        public (int ParentIndexNumber, int IndexNumber)? MinParentAndIndexNumber { get; set; }
 221
 222        public int? AiredDuringSeason { get; set; }
 223
 224        public double? MinCriticRating { get; set; }
 225
 226        public double? MinCommunityRating { get; set; }
 227
 228        public IReadOnlyList<Guid> ChannelIds { get; set; }
 229
 230        public int? ParentIndexNumber { get; set; }
 231
 232        public int? ParentIndexNumberNotEquals { get; set; }
 233
 234        public int? IndexNumber { get; set; }
 235
 236        public ParentalRatingScore? MinParentalRating { get; set; }
 237
 238        public ParentalRatingScore? MaxParentalRating { get; set; }
 239
 240        public bool? HasDeadParentId { get; set; }
 241
 242        public bool? IsVirtualItem { get; set; }
 243
 244        public Guid ParentId { get; set; }
 245
 246        public BaseItemKind? ParentType { get; set; }
 247
 248        public Guid[] AncestorIds { get; set; }
 249
 250        public Guid[] TopParentIds { get; set; }
 251
 252        public CollectionType?[] PresetViews { get; set; }
 253
 254        public TrailerType[] TrailerTypes { get; set; }
 255
 256        public SourceType[] SourceTypes { get; set; }
 257
 258        public SeriesStatus[] SeriesStatuses { get; set; }
 259
 260        public string? ExternalSeriesId { get; set; }
 261
 262        public string? ExternalId { get; set; }
 263
 264        public Guid[] AlbumIds { get; set; }
 265
 266        public Guid[] ArtistIds { get; set; }
 267
 268        public Guid[] ExcludeArtistIds { get; set; }
 269
 270        public string? AncestorWithPresentationUniqueKey { get; set; }
 271
 272        public string? SeriesPresentationUniqueKey { get; set; }
 273
 274        public bool GroupByPresentationUniqueKey { get; set; }
 275
 276        public bool GroupBySeriesPresentationUniqueKey { get; set; }
 277
 278        public bool EnableTotalRecordCount { get; set; }
 279
 280        public bool ForceDirect { get; set; }
 281
 282        public Dictionary<string, string>? ExcludeProviderIds { get; set; }
 283
 284        public bool EnableGroupByMetadataKey { get; set; }
 285
 286        public bool? HasChapterImages { get; set; }
 287
 288        public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
 289
 290        public DateTime? MinDateCreated { get; set; }
 291
 292        public DateTime? MinDateLastSaved { get; set; }
 293
 294        public DateTime? MinDateLastSavedForUser { get; set; }
 295
 296        public DtoOptions DtoOptions { get; set; }
 297
 298        public string? HasNoAudioTrackWithLanguage { get; set; }
 299
 300        public string? HasNoInternalSubtitleTrackWithLanguage { get; set; }
 301
 302        public string? HasNoExternalSubtitleTrackWithLanguage { get; set; }
 303
 304        public string? HasNoSubtitleTrackWithLanguage { get; set; }
 305
 306        public bool? IsDeadArtist { get; set; }
 307
 308        public bool? IsDeadStudio { get; set; }
 309
 310        public bool? IsDeadGenre { get; set; }
 311
 312        public bool? IsDeadPerson { get; set; }
 313
 314        /// <summary>
 315        /// Gets or sets a value indicating whether album sub-folders should be returned if they exist.
 316        /// </summary>
 317        public bool? DisplayAlbumFolders { get; set; }
 318
 319        public BaseItem? Parent
 320        {
 321            set
 322            {
 247323                if (value is null)
 324                {
 54325                    ParentId = Guid.Empty;
 54326                    ParentType = null;
 327                }
 328                else
 329                {
 193330                    ParentId = value.Id;
 193331                    ParentType = value.GetBaseItemKind();
 332                }
 193333            }
 334        }
 335
 336        public Dictionary<string, string>? HasAnyProviderId { get; set; }
 337
 338        public Guid[] AlbumArtistIds { get; set; }
 339
 340        public Guid[] BoxSetLibraryFolders { get; set; }
 341
 342        public Guid[] ContributingArtistIds { get; set; }
 343
 344        public bool? HasAired { get; set; }
 345
 346        public bool? HasOwnerId { get; set; }
 347
 348        public bool? Is4K { get; set; }
 349
 350        public int? MaxHeight { get; set; }
 351
 352        public int? MaxWidth { get; set; }
 353
 354        public int? MinHeight { get; set; }
 355
 356        public int? MinWidth { get; set; }
 357
 358        public string? SearchTerm { get; set; }
 359
 360        public string? SeriesTimerId { get; set; }
 361
 362        public bool SkipDeserialization { get; set; }
 363
 364        public void SetUser(User user)
 365        {
 12366            var maxRating = user.MaxParentalRatingScore;
 12367            if (maxRating.HasValue)
 368            {
 0369                MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore);
 370            }
 371
 12372            var other = UnratedItem.Other.ToString();
 12373            BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
 12374                .Where(i => i != other)
 12375                .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
 376
 12377            ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags)
 12378                .Where(tag => !string.IsNullOrWhiteSpace(tag))
 12379                .Select(tag => tag.RemoveDiacritics().ToLowerInvariant())
 12380                .ToArray();
 381
 12382            IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags)
 12383                .Where(tag => !string.IsNullOrWhiteSpace(tag))
 12384                .Select(tag => tag.RemoveDiacritics().ToLowerInvariant())
 12385                .ToArray();
 386
 12387            User = user;
 12388        }
 389    }
 390}