mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RadicadeServer.DB;
|
||||
using RadicadeServer.Extensions;
|
||||
|
||||
namespace RadicadeServer.Clubs;
|
||||
|
||||
[Route("clubs")]
|
||||
[Route("api/clubs/v1")]
|
||||
[Route("api/clubs/v2")]
|
||||
public class ClubsSearchAPI : Controller
|
||||
{
|
||||
private readonly RecDBContext db;
|
||||
|
||||
public ClubsSearchAPI(RecDBContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
private long ViewerId => User.GetUserId() ?? 0;
|
||||
|
||||
[HttpGet("search/mostactivenow"), Authorize]
|
||||
[HttpGet("mostactivenow"), Authorize]
|
||||
public async Task<IActionResult> GetMostActiveClubs([FromQuery] int skip = 0, [FromQuery] int take = 30)
|
||||
{
|
||||
var clubs = await ClubStore.LoadAsync(db);
|
||||
clubs = ClubStore.FilterByCategory(clubs, ClubStore.CategoryFilter(Request.Query));
|
||||
var items = clubs
|
||||
.Skip(Math.Max(0, skip))
|
||||
.Take(Math.Max(1, take))
|
||||
.Select(x => ClubStore.BuildClub(x, ViewerId))
|
||||
.ToArray();
|
||||
|
||||
return Ok(items);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user