mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
37 lines
915 B
C#
37 lines
915 B
C#
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);
|
|
}
|
|
}
|