Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Nov 12, 2023
1 parent 38e5f52 commit 4161e25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 69 deletions.
3 changes: 3 additions & 0 deletions Shoko.Server/Filters/FilterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static Filterable ToFilterable(this SVR_AnimeSeries series, ILookup<int,
if (subtitleNames.Any()) subtitles = subtitleNames.Aggregate((a, b) => a.Intersect(b, StringComparer.InvariantCultureIgnoreCase)).ToHashSet();
return subtitles;
},
ResolutionsDelegate = () =>
series.GetVideoLocals().Select(a => MediaInfoUtils.GetStandardResolution(Tuple.Create(a.Media.VideoStream.Width, a.Media.VideoStream.Height)))
.ToHashSet()
};

return filterable;
Expand Down
79 changes: 10 additions & 69 deletions Shoko.Server/Filters/FilterableUserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,142 +7,83 @@ namespace Shoko.Server.Filters;
public class FilterableUserInfo : IFilterableUserInfo
{
private readonly Lazy<bool> _hasPermanentVotes;
private readonly Func<bool> _hasPermanentVotesDelegate;

private readonly Lazy<bool> _hasVotes;
private readonly Func<bool> _hasVotesDelegate;

private readonly Lazy<decimal> _highestUserRating;
private readonly Func<decimal> _highestUserRatingDelegate;

private readonly Lazy<bool> _isFavorite;
private readonly Func<bool> _isFavoriteDelegate;

private readonly Lazy<DateTime?> _lastWatchedDate;
private readonly Func<DateTime?> _lastWatchedDateDelegate;

private readonly Lazy<decimal> _lowestUserRating;
private readonly Func<decimal> _lowestUserRatingDelegate;

private readonly Lazy<bool> _missingPermanentVotes;
private readonly Func<bool> _missingPermanentVotesDelegate;

private readonly Lazy<int> _unwatchedEpisodes;
private readonly Func<int> _unwatchedEpisodesDelegate;

private readonly Lazy<DateTime?> _watchedDate;
private readonly Func<DateTime?> _watchedDateDelegate;

private readonly Lazy<int> _watchedEpisodes;
private readonly Func<int> _watchedEpisodesDelegate;

public bool IsFavorite => _isFavorite.Value;

public Func<bool> IsFavoriteDelegate
{
init
{
_isFavoriteDelegate = value;
_isFavorite = new Lazy<bool>(_isFavoriteDelegate, LazyThreadSafetyMode.None);
}
init => _isFavorite = new Lazy<bool>(value);
}

public int WatchedEpisodes => _watchedEpisodes.Value;

public Func<int> WatchedEpisodesDelegate
{
init
{
_watchedEpisodesDelegate = value;
_watchedEpisodes = new Lazy<int>(_watchedEpisodesDelegate, LazyThreadSafetyMode.None);
}
init => _watchedEpisodes = new Lazy<int>(value);
}

public int UnwatchedEpisodes => _unwatchedEpisodes.Value;

public Func<int> UnwatchedEpisodesDelegate
{
init
{
_unwatchedEpisodesDelegate = value;
_unwatchedEpisodes = new Lazy<int>(_unwatchedEpisodesDelegate, LazyThreadSafetyMode.None);
}
init => _unwatchedEpisodes = new Lazy<int>(value);
}

public bool HasVotes => _hasVotes.Value;

public Func<bool> HasVotesDelegate
{
init
{
_hasVotesDelegate = value;
_hasVotes = new Lazy<bool>(_hasVotesDelegate, LazyThreadSafetyMode.None);
}
init => _hasVotes = new Lazy<bool>(value);
}

public bool HasPermanentVotes => _hasPermanentVotes.Value;

public Func<bool> HasPermanentVotesDelegate
{
init
{
_hasPermanentVotesDelegate = value;
_hasPermanentVotes = new Lazy<bool>(_hasPermanentVotesDelegate, LazyThreadSafetyMode.None);
}
init => _hasPermanentVotes = new Lazy<bool>(value);
}

public bool MissingPermanentVotes => _missingPermanentVotes.Value;

public Func<bool> MissingPermanentVotesDelegate
{
init
{
_missingPermanentVotesDelegate = value;
_missingPermanentVotes = new Lazy<bool>(_missingPermanentVotesDelegate, LazyThreadSafetyMode.None);
}
init => _missingPermanentVotes = new Lazy<bool>(value);
}

public DateTime? WatchedDate => _watchedDate.Value;

public Func<DateTime?> WatchedDateDelegate
{
init
{
_watchedDateDelegate = value;
_watchedDate = new Lazy<DateTime?>(_watchedDateDelegate, LazyThreadSafetyMode.None);
}
init => _watchedDate = new Lazy<DateTime?>(value);
}

public DateTime? LastWatchedDate => _lastWatchedDate.Value;

public Func<DateTime?> LastWatchedDateDelegate
{
init
{
_lastWatchedDateDelegate = value;
_lastWatchedDate = new Lazy<DateTime?>(_lastWatchedDateDelegate, LazyThreadSafetyMode.None);
}
init => _lastWatchedDate = new Lazy<DateTime?>(value);
}

public decimal LowestUserRating => _lowestUserRating.Value;

public Func<decimal> LowestUserRatingDelegate
{
init
{
_lowestUserRatingDelegate = value;
_lowestUserRating = new Lazy<decimal>(_lowestUserRatingDelegate, LazyThreadSafetyMode.None);
}
init => _lowestUserRating = new Lazy<decimal>(value);
}

public decimal HighestUserRating => _highestUserRating.Value;

public Func<decimal> HighestUserRatingDelegate
{
init
{
_highestUserRatingDelegate = value;
_highestUserRating = new Lazy<decimal>(_highestUserRatingDelegate, LazyThreadSafetyMode.None);
}
init => _highestUserRating = new Lazy<decimal>(value);
}
}

0 comments on commit 4161e25

Please sign in to comment.