Skip to content

Commit

Permalink
misc: revert how the group stats are updated
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
revam committed Oct 6, 2023
1 parent d4a9222 commit 1aed66c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2200,8 +2200,6 @@ public CL_Response<CL_AnimeSeries_User> 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)
{
Expand Down
2 changes: 0 additions & 2 deletions Shoko.Server/API/v3/Controllers/SeriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,6 @@ public ActionResult MoveSeries([FromRoute] int seriesID, [FromRoute] int groupID

series.MoveSeries(group);

group.TopLevelAnimeGroup?.UpdateStatsFromTopLevel(true, true);

return Ok();
}

Expand Down
2 changes: 1 addition & 1 deletion Shoko.Server/API/v3/Models/Shoko/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion Shoko.Server/Models/SVR_AnimeSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 1aed66c

Please sign in to comment.