< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.UserItemData
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/UserItemData.cs
Line coverage
23%
Covered lines: 3
Uncovered lines: 10
Coverable lines: 13
Total lines: 121
Line coverage: 23%
Branch coverage
8%
Covered branches: 1
Total branches: 12
Branch coverage: 8.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
get_Rating()100%11100%
set_Rating(...)0%4260%
get_Likes()50%2.15266.66%
set_Likes(...)0%2040%

File(s)

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

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using System.Text.Json.Serialization;
 5
 6namespace MediaBrowser.Controller.Entities
 7{
 8    /// <summary>
 9    /// Class UserItemData.
 10    /// </summary>
 11    public class UserItemData
 12    {
 13        public const double MinLikeValue = 6.5;
 14
 15        /// <summary>
 16        /// The _rating.
 17        /// </summary>
 18        private double? _rating;
 19
 20        /// <summary>
 21        /// Gets or sets the key.
 22        /// </summary>
 23        /// <value>The key.</value>
 24        public required string Key { get; set; }
 25
 26        /// <summary>
 27        /// Gets or sets the users 0-10 rating.
 28        /// </summary>
 29        /// <value>The rating.</value>
 30        /// <exception cref="ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</excepti
 31        public double? Rating
 32        {
 2833            get => _rating;
 34            set
 35            {
 036                if (value.HasValue)
 37                {
 038                    if (value.Value < 0 || value.Value > 10)
 39                    {
 040                        throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemD
 41                    }
 42                }
 43
 044                _rating = value;
 045            }
 46        }
 47
 48        /// <summary>
 49        /// Gets or sets the playback position ticks.
 50        /// </summary>
 51        /// <value>The playback position ticks.</value>
 52        public long PlaybackPositionTicks { get; set; }
 53
 54        /// <summary>
 55        /// Gets or sets the play count.
 56        /// </summary>
 57        /// <value>The play count.</value>
 58        public int PlayCount { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets a value indicating whether this instance is favorite.
 62        /// </summary>
 63        /// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
 64        public bool IsFavorite { get; set; }
 65
 66        /// <summary>
 67        /// Gets or sets the last played date.
 68        /// </summary>
 69        /// <value>The last played date.</value>
 70        public DateTime? LastPlayedDate { get; set; }
 71
 72        /// <summary>
 73        /// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
 74        /// </summary>
 75        /// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
 76        public bool Played { get; set; }
 77
 78        /// <summary>
 79        /// Gets or sets the index of the audio stream.
 80        /// </summary>
 81        /// <value>The index of the audio stream.</value>
 82        public int? AudioStreamIndex { get; set; }
 83
 84        /// <summary>
 85        /// Gets or sets the index of the subtitle stream.
 86        /// </summary>
 87        /// <value>The index of the subtitle stream.</value>
 88        public int? SubtitleStreamIndex { get; set; }
 89
 90        /// <summary>
 91        /// Gets or sets a value indicating whether the item is liked or not.
 92        /// This should never be serialized.
 93        /// </summary>
 94        /// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
 95        [JsonIgnore]
 96        public bool? Likes
 97        {
 98            get
 99            {
 14100                if (Rating is not null)
 101                {
 0102                    return Rating >= MinLikeValue;
 103                }
 104
 14105                return null;
 106            }
 107
 108            set
 109            {
 0110                if (value.HasValue)
 111                {
 0112                    Rating = value.Value ? 10 : 1;
 113                }
 114                else
 115                {
 0116                    Rating = null;
 117                }
 0118            }
 119        }
 120    }
 121}