From f1d07f74ee05587dc7baf7d55a6504cea18cb273 Mon Sep 17 00:00:00 2001 From: Daniel Martin Gonzalez Date: Sun, 27 Feb 2022 10:18:13 +0100 Subject: [PATCH] New: Option to show release group column on series list --- .../Series/Index/Table/SeriesIndexHeader.css | 1 + .../src/Series/Index/Table/SeriesIndexRow.css | 1 + .../src/Series/Index/Table/SeriesIndexRow.js | 22 +++++++++++++++- frontend/src/Store/Actions/seriesActions.js | 17 ++++++++++++ .../src/Store/Actions/seriesIndexActions.js | 6 +++++ .../SeriesStats/SeasonStatistics.cs | 26 ++++++++++++++++++- .../SeriesStats/SeriesStatistics.cs | 1 + .../SeriesStats/SeriesStatisticsRepository.cs | 2 +- .../SeriesStats/SeriesStatisticsService.cs | 3 ++- .../Series/SeasonStatisticsResource.cs | 5 +++- .../Series/SeriesStatisticsResource.cs | 4 ++- 11 files changed, 82 insertions(+), 6 deletions(-) diff --git a/frontend/src/Series/Index/Table/SeriesIndexHeader.css b/frontend/src/Series/Index/Table/SeriesIndexHeader.css index 6781ef951..ce9f0f6ed 100644 --- a/frontend/src/Series/Index/Table/SeriesIndexHeader.css +++ b/frontend/src/Series/Index/Table/SeriesIndexHeader.css @@ -37,6 +37,7 @@ flex: 1 0 125px; } +.releaseGroups, .nextAiring, .previousAiring, .added, diff --git a/frontend/src/Series/Index/Table/SeriesIndexRow.css b/frontend/src/Series/Index/Table/SeriesIndexRow.css index c67a02479..df4b4b9ab 100644 --- a/frontend/src/Series/Index/Table/SeriesIndexRow.css +++ b/frontend/src/Series/Index/Table/SeriesIndexRow.css @@ -73,6 +73,7 @@ flex: 1 0 125px; } +.releaseGroups, .nextAiring, .previousAiring, .added, diff --git a/frontend/src/Series/Index/Table/SeriesIndexRow.js b/frontend/src/Series/Index/Table/SeriesIndexRow.js index e6161ec9f..2732030ed 100644 --- a/frontend/src/Series/Index/Table/SeriesIndexRow.js +++ b/frontend/src/Series/Index/Table/SeriesIndexRow.js @@ -114,6 +114,7 @@ class SeriesIndexRow extends Component { episodeCount, episodeFileCount, totalEpisodeCount, + releaseGroups, sizeOnDisk } = statistics; @@ -413,6 +414,24 @@ class SeriesIndexRow extends Component { ); } + if (name === 'releaseGroups') { + const joinedReleaseGroups = releaseGroups.join(', '); + const truncatedReleaseGroups = releaseGroups.length > 3 ? + `${releaseGroups.slice(0, 3).join(', ')}...` : + joinedReleaseGroups; + + return ( + + + {truncatedReleaseGroups} + + + ); + } + if (name === 'tags') { return ( ReleaseGroups + { + get + { + var releasegroups = new List(); + + if (ReleaseGroupsString.IsNotNullOrWhiteSpace()) + { + releasegroups = ReleaseGroupsString + .Split('|') + .Distinct() + .Where(rg => rg.IsNotNullOrWhiteSpace()) + .OrderBy(rg => rg) + .ToList(); + } + + return releasegroups; + } + } } } diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs index 363d1f346..44f477c0b 100644 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs +++ b/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Core.SeriesStats public int EpisodeCount { get; set; } public int TotalEpisodeCount { get; set; } public long SizeOnDisk { get; set; } + public List ReleaseGroups { get; set; } public List SeasonStatistics { get; set; } public DateTime? NextAiring diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs index 699531198..469dfd2f0 100644 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs +++ b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsRepository.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Core.SeriesStats private string GetSelectClause(bool series) { - return @"SELECT Episodes.*, SUM(EpisodeFiles.Size) as SizeOnDisk FROM + return @"SELECT Episodes.*, SUM(EpisodeFiles.Size) as SizeOnDisk, GROUP_CONCAT(EpisodeFiles.ReleaseGroup, '|') AS ReleaseGroupsString FROM (SELECT Episodes.SeriesId, Episodes.SeasonNumber, diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs index b273f84ce..2c1900f9a 100644 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs +++ b/src/NzbDrone.Core/SeriesStats/SeriesStatisticsService.cs @@ -43,7 +43,8 @@ namespace NzbDrone.Core.SeriesStats EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount), EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount), TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount), - SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk) + SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk), + ReleaseGroups = seasonStatistics.SelectMany(s => s.ReleaseGroups).Distinct().ToList() }; var nextAiring = seasonStatistics.Where(s => s.NextAiring != null) diff --git a/src/Sonarr.Api.V3/Series/SeasonStatisticsResource.cs b/src/Sonarr.Api.V3/Series/SeasonStatisticsResource.cs index 12ee9434f..e482cd12a 100644 --- a/src/Sonarr.Api.V3/Series/SeasonStatisticsResource.cs +++ b/src/Sonarr.Api.V3/Series/SeasonStatisticsResource.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using NzbDrone.Core.SeriesStats; namespace Sonarr.Api.V3.Series @@ -11,6 +12,7 @@ namespace Sonarr.Api.V3.Series public int EpisodeCount { get; set; } public int TotalEpisodeCount { get; set; } public long SizeOnDisk { get; set; } + public List ReleaseGroups { get; set; } public decimal PercentOfEpisodes { @@ -36,7 +38,8 @@ namespace Sonarr.Api.V3.Series EpisodeFileCount = model.EpisodeFileCount, EpisodeCount = model.EpisodeCount, TotalEpisodeCount = model.TotalEpisodeCount, - SizeOnDisk = model.SizeOnDisk + SizeOnDisk = model.SizeOnDisk, + ReleaseGroups = model.ReleaseGroups }; } } diff --git a/src/Sonarr.Api.V3/Series/SeriesStatisticsResource.cs b/src/Sonarr.Api.V3/Series/SeriesStatisticsResource.cs index a2c797b95..dcdecbdf2 100644 --- a/src/Sonarr.Api.V3/Series/SeriesStatisticsResource.cs +++ b/src/Sonarr.Api.V3/Series/SeriesStatisticsResource.cs @@ -11,6 +11,7 @@ namespace Sonarr.Api.V3.Series public int EpisodeCount { get; set; } public int TotalEpisodeCount { get; set; } public long SizeOnDisk { get; set; } + public List ReleaseGroups { get; set; } public decimal PercentOfEpisodes { @@ -37,7 +38,8 @@ namespace Sonarr.Api.V3.Series EpisodeFileCount = model.EpisodeFileCount, EpisodeCount = model.EpisodeCount, TotalEpisodeCount = model.TotalEpisodeCount, - SizeOnDisk = model.SizeOnDisk + SizeOnDisk = model.SizeOnDisk, + ReleaseGroups = model.ReleaseGroups }; } }