< 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: 58
Uncovered lines: 1
Coverable lines: 59
Total lines: 382
Line coverage: 98.3%
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%2290.9%

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;
 7using Jellyfin.Data.Enums;
 8using Jellyfin.Database.Implementations.Entities;
 9using Jellyfin.Database.Implementations.Enums;
 10using MediaBrowser.Controller.Dto;
 11using MediaBrowser.Model.Entities;
 12
 13namespace MediaBrowser.Controller.Entities
 14{
 15    public class InternalItemsQuery
 16    {
 17        public InternalItemsQuery()
 18        {
 50619            AlbumArtistIds = Array.Empty<Guid>();
 50620            AlbumIds = Array.Empty<Guid>();
 50621            AncestorIds = Array.Empty<Guid>();
 50622            ArtistIds = Array.Empty<Guid>();
 50623            BlockUnratedItems = Array.Empty<UnratedItem>();
 50624            BoxSetLibraryFolders = Array.Empty<Guid>();
 50625            ChannelIds = Array.Empty<Guid>();
 50626            ContributingArtistIds = Array.Empty<Guid>();
 50627            DtoOptions = new DtoOptions();
 50628            EnableTotalRecordCount = true;
 50629            ExcludeArtistIds = Array.Empty<Guid>();
 50630            ExcludeInheritedTags = Array.Empty<string>();
 50631            IncludeInheritedTags = Array.Empty<string>();
 50632            ExcludeItemIds = Array.Empty<Guid>();
 50633            ExcludeItemTypes = Array.Empty<BaseItemKind>();
 50634            ExcludeTags = Array.Empty<string>();
 50635            GenreIds = Array.Empty<Guid>();
 50636            Genres = Array.Empty<string>();
 50637            GroupByPresentationUniqueKey = true;
 50638            ImageTypes = Array.Empty<ImageType>();
 50639            IncludeItemTypes = Array.Empty<BaseItemKind>();
 50640            ItemIds = Array.Empty<Guid>();
 50641            MediaTypes = Array.Empty<MediaType>();
 50642            OfficialRatings = Array.Empty<string>();
 50643            OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
 50644            PersonIds = Array.Empty<Guid>();
 50645            PersonTypes = Array.Empty<string>();
 50646            PresetViews = Array.Empty<CollectionType?>();
 50647            SeriesStatuses = Array.Empty<SeriesStatus>();
 50648            SourceTypes = Array.Empty<SourceType>();
 50649            StudioIds = Array.Empty<Guid>();
 50650            Tags = Array.Empty<string>();
 50651            TopParentIds = Array.Empty<Guid>();
 50652            TrailerTypes = Array.Empty<TrailerType>();
 50653            VideoTypes = Array.Empty<VideoType>();
 50654            Years = Array.Empty<int>();
 50655            SkipDeserialization = false;
 50656        }
 57
 58        public InternalItemsQuery(User? user)
 1259            : this()
 60        {
 1261            if (user is not null)
 62            {
 1263                SetUser(user);
 64            }
 1265        }
 66
 67        public bool Recursive { get; set; }
 68
 69        public int? StartIndex { get; set; }
 70
 71        public int? Limit { get; set; }
 72
 73        public User? User { get; set; }
 74
 75        public bool? IsFolder { get; set; }
 76
 77        public bool? IsFavorite { get; set; }
 78
 79        public bool? IsFavoriteOrLiked { get; set; }
 80
 81        public bool? IsLiked { get; set; }
 82
 83        public bool? IsPlayed { get; set; }
 84
 85        public bool? IsResumable { get; set; }
 86
 87        public bool? IncludeItemsByName { get; set; }
 88
 89        public MediaType[] MediaTypes { get; set; }
 90
 91        public BaseItemKind[] IncludeItemTypes { get; set; }
 92
 93        public BaseItemKind[] ExcludeItemTypes { get; set; }
 94
 95        public string[] ExcludeTags { get; set; }
 96
 97        public string[] ExcludeInheritedTags { get; set; }
 98
 99        public string[] IncludeInheritedTags { get; set; }
 100
 101        public IReadOnlyList<string> Genres { get; set; }
 102
 103        public bool? IsSpecialSeason { get; set; }
 104
 105        public bool? IsMissing { get; set; }
 106
 107        public bool? IsUnaired { get; set; }
 108
 109        public bool? CollapseBoxSetItems { get; set; }
 110
 111        public string? NameStartsWithOrGreater { get; set; }
 112
 113        public string? NameStartsWith { get; set; }
 114
 115        public string? NameLessThan { get; set; }
 116
 117        public string? NameContains { get; set; }
 118
 119        public string? MinSortName { get; set; }
 120
 121        public string? PresentationUniqueKey { get; set; }
 122
 123        public string? Path { get; set; }
 124
 125        public string? Name { get; set; }
 126
 127        public string? Person { get; set; }
 128
 129        public Guid[] PersonIds { get; set; }
 130
 131        public Guid[] ItemIds { get; set; }
 132
 133        public Guid[] ExcludeItemIds { get; set; }
 134
 135        public Guid? AdjacentTo { get; set; }
 136
 137        public string[] PersonTypes { get; set; }
 138
 139        public bool? Is3D { get; set; }
 140
 141        public bool? IsHD { get; set; }
 142
 143        public bool? IsLocked { get; set; }
 144
 145        public bool? IsPlaceHolder { get; set; }
 146
 147        public bool? HasImdbId { get; set; }
 148
 149        public bool? HasOverview { get; set; }
 150
 151        public bool? HasTmdbId { get; set; }
 152
 153        public bool? HasOfficialRating { get; set; }
 154
 155        public bool? HasTvdbId { get; set; }
 156
 157        public bool? HasThemeSong { get; set; }
 158
 159        public bool? HasThemeVideo { get; set; }
 160
 161        public bool? HasSubtitles { get; set; }
 162
 163        public bool? HasSpecialFeature { get; set; }
 164
 165        public bool? HasTrailer { get; set; }
 166
 167        public bool? HasParentalRating { get; set; }
 168
 169        public Guid[] StudioIds { get; set; }
 170
 171        public IReadOnlyList<Guid> GenreIds { get; set; }
 172
 173        public ImageType[] ImageTypes { get; set; }
 174
 175        public VideoType[] VideoTypes { get; set; }
 176
 177        public UnratedItem[] BlockUnratedItems { get; set; }
 178
 179        public int[] Years { get; set; }
 180
 181        public string[] Tags { get; set; }
 182
 183        public string[] OfficialRatings { get; set; }
 184
 185        public DateTime? MinPremiereDate { get; set; }
 186
 187        public DateTime? MaxPremiereDate { get; set; }
 188
 189        public DateTime? MinStartDate { get; set; }
 190
 191        public DateTime? MaxStartDate { get; set; }
 192
 193        public DateTime? MinEndDate { get; set; }
 194
 195        public DateTime? MaxEndDate { get; set; }
 196
 197        public bool? IsAiring { get; set; }
 198
 199        public bool? IsMovie { get; set; }
 200
 201        public bool? IsSports { get; set; }
 202
 203        public bool? IsKids { get; set; }
 204
 205        public bool? IsNews { get; set; }
 206
 207        public bool? IsSeries { get; set; }
 208
 209        public int? MinIndexNumber { get; set; }
 210
 211        /// <summary>
 212        /// Gets or sets the minimum ParentIndexNumber and IndexNumber.
 213        /// </summary>
 214        /// <remarks>
 215        /// It produces this where clause:
 216        /// <para>(ParentIndexNumber = X and IndexNumber >= Y) or ParentIndexNumber > X.
 217        /// </para>
 218        /// </remarks>
 219        public (int ParentIndexNumber, int IndexNumber)? MinParentAndIndexNumber { get; set; }
 220
 221        public int? AiredDuringSeason { get; set; }
 222
 223        public double? MinCriticRating { get; set; }
 224
 225        public double? MinCommunityRating { get; set; }
 226
 227        public IReadOnlyList<Guid> ChannelIds { get; set; }
 228
 229        public int? ParentIndexNumber { get; set; }
 230
 231        public int? ParentIndexNumberNotEquals { get; set; }
 232
 233        public int? IndexNumber { get; set; }
 234
 235        public ParentalRatingScore? MinParentalRating { get; set; }
 236
 237        public ParentalRatingScore? MaxParentalRating { get; set; }
 238
 239        public bool? HasDeadParentId { get; set; }
 240
 241        public bool? IsVirtualItem { get; set; }
 242
 243        public Guid ParentId { get; set; }
 244
 245        public BaseItemKind? ParentType { get; set; }
 246
 247        public Guid[] AncestorIds { get; set; }
 248
 249        public Guid[] TopParentIds { get; set; }
 250
 251        public CollectionType?[] PresetViews { get; set; }
 252
 253        public TrailerType[] TrailerTypes { get; set; }
 254
 255        public SourceType[] SourceTypes { get; set; }
 256
 257        public SeriesStatus[] SeriesStatuses { get; set; }
 258
 259        public string? ExternalSeriesId { get; set; }
 260
 261        public string? ExternalId { get; set; }
 262
 263        public Guid[] AlbumIds { get; set; }
 264
 265        public Guid[] ArtistIds { get; set; }
 266
 267        public Guid[] ExcludeArtistIds { get; set; }
 268
 269        public string? AncestorWithPresentationUniqueKey { get; set; }
 270
 271        public string? SeriesPresentationUniqueKey { get; set; }
 272
 273        public bool GroupByPresentationUniqueKey { get; set; }
 274
 275        public bool GroupBySeriesPresentationUniqueKey { get; set; }
 276
 277        public bool EnableTotalRecordCount { get; set; }
 278
 279        public bool ForceDirect { get; set; }
 280
 281        public Dictionary<string, string>? ExcludeProviderIds { get; set; }
 282
 283        public bool EnableGroupByMetadataKey { get; set; }
 284
 285        public bool? HasChapterImages { get; set; }
 286
 287        public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
 288
 289        public DateTime? MinDateCreated { get; set; }
 290
 291        public DateTime? MinDateLastSaved { get; set; }
 292
 293        public DateTime? MinDateLastSavedForUser { get; set; }
 294
 295        public DtoOptions DtoOptions { get; set; }
 296
 297        public string? HasNoAudioTrackWithLanguage { get; set; }
 298
 299        public string? HasNoInternalSubtitleTrackWithLanguage { get; set; }
 300
 301        public string? HasNoExternalSubtitleTrackWithLanguage { get; set; }
 302
 303        public string? HasNoSubtitleTrackWithLanguage { get; set; }
 304
 305        public bool? IsDeadArtist { get; set; }
 306
 307        public bool? IsDeadStudio { get; set; }
 308
 309        public bool? IsDeadGenre { get; set; }
 310
 311        public bool? IsDeadPerson { get; set; }
 312
 313        /// <summary>
 314        /// Gets or sets a value indicating whether album sub-folders should be returned if they exist.
 315        /// </summary>
 316        public bool? DisplayAlbumFolders { get; set; }
 317
 318        public BaseItem? Parent
 319        {
 320            set
 321            {
 249322                if (value is null)
 323                {
 52324                    ParentId = Guid.Empty;
 52325                    ParentType = null;
 326                }
 327                else
 328                {
 197329                    ParentId = value.Id;
 197330                    ParentType = value.GetBaseItemKind();
 331                }
 197332            }
 333        }
 334
 335        public Dictionary<string, string>? HasAnyProviderId { get; set; }
 336
 337        public Guid[] AlbumArtistIds { get; set; }
 338
 339        public Guid[] BoxSetLibraryFolders { get; set; }
 340
 341        public Guid[] ContributingArtistIds { get; set; }
 342
 343        public bool? HasAired { get; set; }
 344
 345        public bool? HasOwnerId { get; set; }
 346
 347        public bool? Is4K { get; set; }
 348
 349        public int? MaxHeight { get; set; }
 350
 351        public int? MaxWidth { get; set; }
 352
 353        public int? MinHeight { get; set; }
 354
 355        public int? MinWidth { get; set; }
 356
 357        public string? SearchTerm { get; set; }
 358
 359        public string? SeriesTimerId { get; set; }
 360
 361        public bool SkipDeserialization { get; set; }
 362
 363        public void SetUser(User user)
 364        {
 12365            var maxRating = user.MaxParentalRatingScore;
 12366            if (maxRating.HasValue)
 367            {
 0368                MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore);
 369            }
 370
 12371            var other = UnratedItem.Other.ToString();
 12372            BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
 12373                .Where(i => i != other)
 12374                .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
 375
 12376            ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
 12377            IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags);
 378
 12379            User = user;
 12380        }
 381    }
 382}