Skip to content

Commit

Permalink
refactor: remove IEnumerableExtensions.
Browse files Browse the repository at this point in the history
Should've done this earlier since the air dates could be reduced
to a one-liner.
  • Loading branch information
revam committed Aug 19, 2022
1 parent fcb60ef commit fb09749
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 36 deletions.
3 changes: 1 addition & 2 deletions Shoko.Server/API/v3/Controllers/GroupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Shoko.Server.API.v3.Helpers;
using Shoko.Server.API.v3.Models.Common;
using Shoko.Server.API.v3.Models.Shoko;
using Shoko.Server.Extensions;
using Shoko.Server.Models;
using Shoko.Server.Repositories;
using Shoko.Server.Tasks;
Expand Down Expand Up @@ -58,7 +57,7 @@ public ActionResult<ListResult<Group>> GetAllGroups([FromQuery] [Range(0, 100)]

return includeEmpty || group.GetAllSeries().Any(s => s.GetAnimeEpisodes().Any(e => e.GetVideoLocals().Count > 0));
})
.OrderByName()
.OrderBy(group => group.GroupName)
.ToListResult(group => new Group(HttpContext, group, randomImages), page, pageSize);
}

Expand Down
11 changes: 5 additions & 6 deletions Shoko.Server/API/v3/Controllers/TreeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Shoko.Server.API.v3.Helpers;
using Shoko.Server.API.v3.Models.Common;
using Shoko.Server.API.v3.Models.Shoko;
using Shoko.Server.Extensions;
using Shoko.Server.Models;
using Shoko.Server.Repositories;

Expand Down Expand Up @@ -49,7 +48,7 @@ public ActionResult<ListResult<Filter>> GetSubFilters([FromRoute] int filterID,

return RepoFactory.GroupFilter.GetByParentID(filterID)
.Where(filter => showHidden || filter.InvisibleInClients != 1)
.OrderByName()
.OrderBy(filter => filter.GroupFilterName)
.ToListResult(filter => new Filter(HttpContext, filter), page, pageSize);
}

Expand All @@ -72,7 +71,7 @@ public ActionResult<ListResult<Group>> GetFilteredGroups([FromRoute] int filterI
var user = User;
groups = RepoFactory.AnimeGroup.GetAll()
.Where(group => !group.AnimeGroupParentID.HasValue && user.AllowedGroup(group))
.OrderByName();
.OrderBy(group => group.GroupName);
}
else
{
Expand Down Expand Up @@ -196,7 +195,7 @@ public ActionResult<List<Series>> GetSeriesInFilteredGroup([FromRoute] int filte

return (recursive ? group.GetAllSeries() : group.GetSeries())
.Where(series => seriesIDs.Contains(series.AnimeSeriesID))
.OrderByAirDate()
.OrderBy(series => series.GetAnime()?.AirDate ?? DateTime.MaxValue)
.Select(series => new Series(HttpContext, series))
.Where(series => series.Size > 0 || includeMissing)
.ToList();
Expand Down Expand Up @@ -235,7 +234,7 @@ public ActionResult<List<Group>> GetSubGroups([FromRoute] int groupID, [FromQuer

return includeEmpty || group.GetAllSeries().Any(s => s.GetAnimeEpisodes().Any(e => e.GetVideoLocals().Count > 0));
})
.OrderByName()
.OrderBy(group => group.GroupName)
.Select(group => new Group(HttpContext, group, randomImages))
.ToList();
}
Expand Down Expand Up @@ -263,7 +262,7 @@ public ActionResult<List<Series>> GetSeriesInGroup([FromRoute] int groupID, [Fro
var user = User;
return (recursive ? group.GetAllSeries() : group.GetSeries())
.Where(a => user.AllowedSeries(a))
.OrderByAirDate()
.OrderBy(series => series.GetAnime()?.AirDate ?? DateTime.MaxValue)
.Select(series => new Series(HttpContext, series, randomImages))
.Where(series => series.Size > 0 || includeMissing)
.ToList();
Expand Down
27 changes: 0 additions & 27 deletions Shoko.Server/Extensions/IEnumerableExtenions.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Shoko.Server/Models/SVR_AnimeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public SVR_AnimeSeries GetMainSeries()

// Earliest airing series.
return GetAllSeries()
.OrderByAirDate()
.OrderBy(series => series.GetAnime()?.AirDate ?? DateTime.MaxValue)
.FirstOrDefault();
}

Expand Down

0 comments on commit fb09749

Please sign in to comment.