From 1aed66c128e9b824f63a5c7d8b6bbb1565a5e38a Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Fri, 6 Oct 2023 03:00:41 +0200 Subject: [PATCH] misc: revert how the group stats are updated - so move it back into the `MoveSeries` method, but make it optional, then disable it for when we're creating/modifying the group in the v3 path, since we're updating the stats for the group at the end, after all the series have been moved into the group. --- .../ShokoServiceImplementation_Entities.cs | 2 -- Shoko.Server/API/v3/Controllers/SeriesController.cs | 2 -- Shoko.Server/API/v3/Models/Shoko/Group.cs | 2 +- Shoko.Server/Models/SVR_AnimeSeries.cs | 4 +++- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Shoko.Server/API/v1/Implementations/ShokoServiceImplementation/ShokoServiceImplementation_Entities.cs b/Shoko.Server/API/v1/Implementations/ShokoServiceImplementation/ShokoServiceImplementation_Entities.cs index 20c73f183..96688f016 100755 --- a/Shoko.Server/API/v1/Implementations/ShokoServiceImplementation/ShokoServiceImplementation_Entities.cs +++ b/Shoko.Server/API/v1/Implementations/ShokoServiceImplementation/ShokoServiceImplementation_Entities.cs @@ -2200,8 +2200,6 @@ public CL_Response MoveSeries(int animeSeriesID, int newAni ser.MoveSeries(grp); - grp.TopLevelAnimeGroup?.UpdateStatsFromTopLevel(true, true); - var anime = RepoFactory.AniDB_Anime.GetByAnimeID(ser.AniDB_ID); if (anime == null) { diff --git a/Shoko.Server/API/v3/Controllers/SeriesController.cs b/Shoko.Server/API/v3/Controllers/SeriesController.cs index 666183461..60dd2480f 100644 --- a/Shoko.Server/API/v3/Controllers/SeriesController.cs +++ b/Shoko.Server/API/v3/Controllers/SeriesController.cs @@ -1448,8 +1448,6 @@ public ActionResult MoveSeries([FromRoute] int seriesID, [FromRoute] int groupID series.MoveSeries(group); - group.TopLevelAnimeGroup?.UpdateStatsFromTopLevel(true, true); - return Ok(); } diff --git a/Shoko.Server/API/v3/Models/Shoko/Group.cs b/Shoko.Server/API/v3/Models/Shoko/Group.cs index b93b2c40f..48220f586 100644 --- a/Shoko.Server/API/v3/Models/Shoko/Group.cs +++ b/Shoko.Server/API/v3/Models/Shoko/Group.cs @@ -376,7 +376,7 @@ public CreateOrUpdateGroupBody(SVR_AnimeGroup group) // Move the series over to the new group. foreach (var series in seriesList) - series.MoveSeries(group); + series.MoveSeries(group, updateGroupStats: false); // Set the main series and maybe update the group // name/description. diff --git a/Shoko.Server/Models/SVR_AnimeSeries.cs b/Shoko.Server/Models/SVR_AnimeSeries.cs index ec50faf95..1e26f1410 100644 --- a/Shoko.Server/Models/SVR_AnimeSeries.cs +++ b/Shoko.Server/Models/SVR_AnimeSeries.cs @@ -1537,7 +1537,7 @@ public bool Hidden } } - public void MoveSeries(SVR_AnimeGroup newGroup) + public void MoveSeries(SVR_AnimeGroup newGroup, bool updateGroupStats = true) { // Skip moving series if it's already part of the group. if (AnimeGroupID == newGroup.AnimeGroupID) @@ -1548,6 +1548,8 @@ public void MoveSeries(SVR_AnimeGroup newGroup) AnimeGroupID = newGroup.AnimeGroupID; DateTimeUpdated = DateTime.Now; UpdateStats(true, true); + if (updateGroupStats) + newGroup.TopLevelAnimeGroup?.UpdateStatsFromTopLevel(true, true); var oldGroup = RepoFactory.AnimeGroup.GetByID(oldGroupID); if (oldGroup != null)