< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.InternalItemsQuery
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
Line coverage
93%
Covered lines: 55
Uncovered lines: 4
Coverable lines: 59
Total lines: 382
Line coverage: 93.2%
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%2.26260%

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 Jellyfin.Data.Entities;
 7using Jellyfin.Data.Enums;
 8using MediaBrowser.Controller.Dto;
 9using MediaBrowser.Model.Entities;
 10
 11namespace MediaBrowser.Controller.Entities
 12{
 13    public class InternalItemsQuery
 14    {
 15        public InternalItemsQuery()
 16        {
 35117            AlbumArtistIds = Array.Empty<Guid>();
 35118            AlbumIds = Array.Empty<Guid>();
 35119            AncestorIds = Array.Empty<Guid>();
 35120            ArtistIds = Array.Empty<Guid>();
 35121            BlockUnratedItems = Array.Empty<UnratedItem>();
 35122            BoxSetLibraryFolders = Array.Empty<Guid>();
 35123            ChannelIds = Array.Empty<Guid>();
 35124            ContributingArtistIds = Array.Empty<Guid>();
 35125            DtoOptions = new DtoOptions();
 35126            EnableTotalRecordCount = true;
 35127            ExcludeArtistIds = Array.Empty<Guid>();
 35128            ExcludeInheritedTags = Array.Empty<string>();
 35129            IncludeInheritedTags = Array.Empty<string>();
 35130            ExcludeItemIds = Array.Empty<Guid>();
 35131            ExcludeItemTypes = Array.Empty<BaseItemKind>();
 35132            ExcludeTags = Array.Empty<string>();
 35133            GenreIds = Array.Empty<Guid>();
 35134            Genres = Array.Empty<string>();
 35135            GroupByPresentationUniqueKey = true;
 35136            ImageTypes = Array.Empty<ImageType>();
 35137            IncludeItemTypes = Array.Empty<BaseItemKind>();
 35138            ItemIds = Array.Empty<Guid>();
 35139            MediaTypes = Array.Empty<MediaType>();
 35140            MinSimilarityScore = 20;
 35141            OfficialRatings = Array.Empty<string>();
 35142            OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
 35143            PersonIds = Array.Empty<Guid>();
 35144            PersonTypes = Array.Empty<string>();
 35145            PresetViews = Array.Empty<CollectionType?>();
 35146            SeriesStatuses = Array.Empty<SeriesStatus>();
 35147            SourceTypes = Array.Empty<SourceType>();
 35148            StudioIds = Array.Empty<Guid>();
 35149            Tags = Array.Empty<string>();
 35150            TopParentIds = Array.Empty<Guid>();
 35151            TrailerTypes = Array.Empty<TrailerType>();
 35152            VideoTypes = Array.Empty<VideoType>();
 35153            Years = Array.Empty<int>();
 35154            SkipDeserialization = false;
 35155        }
 56
 57        public InternalItemsQuery(User? user)
 1758            : this()
 59        {
 1760            if (user is not null)
 61            {
 1762                SetUser(user);
 63            }
 1764        }
 65
 66        public bool Recursive { get; set; }
 67
 68        public int? StartIndex { get; set; }
 69
 70        public int? Limit { get; set; }
 71
 72        public User? User { get; set; }
 73
 74        public BaseItem? SimilarTo { 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 int? MinParentalRating { get; set; }
 237
 238        public int? 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 int MinSimilarityScore { 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? 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                {
 30325                    ParentId = Guid.Empty;
 30326                    ParentType = null;
 327                }
 328                else
 329                {
 217330                    ParentId = value.Id;
 217331                    ParentType = value.GetBaseItemKind();
 332                }
 217333            }
 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        {
 17366            MaxParentalRating = user.MaxParentalAgeRating;
 367
 17368            if (MaxParentalRating.HasValue)
 369            {
 0370                string other = UnratedItem.Other.ToString();
 0371                BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
 0372                    .Where(i => i != other)
 0373                    .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
 374            }
 375
 17376            ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
 17377            IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags);
 378
 17379            User = user;
 17380        }
 381    }
 382}