-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update used release group query
and add v3 release group endpoint to get used, unused, or all anidb release groups.
- Loading branch information
Showing
6 changed files
with
134 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Shoko.Server.API.Annotations; | ||
using Shoko.Server.API.v3.Helpers; | ||
using Shoko.Server.API.v3.Models.Common; | ||
using Shoko.Server.API.v3.Models.Shoko; | ||
using Shoko.Server.Repositories; | ||
using Shoko.Server.Settings; | ||
|
||
namespace Shoko.Server.API.v3.Controllers; | ||
|
||
[ApiController] | ||
[Route("/api/v{version:apiVersion}/[controller]")] | ||
[ApiV3] | ||
[Authorize] | ||
public class AniDBController : BaseController | ||
{ | ||
/// <summary> | ||
/// Get the known anidb release groups stored in shoko. | ||
/// </summary> | ||
/// <param name="pageSize">The page size. Set to <code>0</code> to disable pagination.</param> | ||
/// <param name="page">The page index.</param> | ||
/// <param name="includeMissing">Include missing release groups.</param> | ||
/// <returns></returns> | ||
[HttpGet("ReleaseGroup")] | ||
public ActionResult<ListResult<ReleaseGroup>> GetReleaseGroups( | ||
[FromQuery, Range(0, 1000)] int pageSize = 20, | ||
[FromQuery, Range(1, int.MaxValue)] int page = 1, | ||
[FromQuery] IncludeOnlyFilter includeMissing = IncludeOnlyFilter.False) | ||
{ | ||
return includeMissing switch | ||
{ | ||
IncludeOnlyFilter.False => RepoFactory.AniDB_ReleaseGroup.GetUsedReleaseGroups() | ||
.ToListResult(g => new ReleaseGroup(g), page, pageSize), | ||
IncludeOnlyFilter.Only => RepoFactory.AniDB_ReleaseGroup.GetUnusedReleaseGroups() | ||
.ToListResult(g => new ReleaseGroup(g), page, pageSize), | ||
_ => RepoFactory.AniDB_ReleaseGroup.GetAll() | ||
.ToListResult(g => new ReleaseGroup(g), page, pageSize), | ||
}; | ||
} | ||
|
||
public AniDBController(ISettingsProvider settingsProvider) : base(settingsProvider) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
using Shoko.Models.Server; | ||
|
||
namespace Shoko.Server.API.v3.Models.Shoko; | ||
|
||
|
||
public class ReleaseGroup | ||
{ | ||
/// <summary> | ||
/// AniDB release group ID (69) | ||
/// /// </summary> | ||
public int ID { get; set; } | ||
|
||
/// <summary> | ||
/// The Release Group's Name (Unlimited Translation Works) | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// The Release Group's Name (UTW) | ||
/// </summary> | ||
public string ShortName { get; set; } | ||
|
||
/// <summary> | ||
/// Source. Anidb, User, etc. | ||
/// </summary> | ||
/// <value></value> | ||
public string Source { get; set; } | ||
|
||
public ReleaseGroup(AniDB_ReleaseGroup group) | ||
{ | ||
ID = group.GroupID; | ||
Name = group.GroupName; | ||
ShortName = group.ShortName; | ||
Source = "AniDB"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters