Add knowledge item and innovation CRUD with search/filtering, published-only visibility for non-staff, admin publish/update, challenge dictionary, problem aggregation with trends (admin only) and canonical embedding text preparation for matchmaking.
38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using Asp.Versioning;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using TarninaHub.Application.Abstractions;
|
|
using TarninaHub.Application.Dtos;
|
|
using TarninaHub.Application.Security;
|
|
|
|
namespace TarninaHub.Controllers;
|
|
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/trends")]
|
|
[Authorize(Policy = Policies.OperatorOrAdmin)]
|
|
public class TrendsController : ControllerBase
|
|
{
|
|
private readonly ITrendService _trends;
|
|
|
|
public TrendsController(ITrendService trends)
|
|
{
|
|
_trends = trends;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<TrendsResponse>> Get(
|
|
[FromQuery] string? challengeId,
|
|
[FromQuery] DateTimeOffset? from,
|
|
[FromQuery] DateTimeOffset? to,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
var rangeEnd = to ?? DateTimeOffset.UtcNow;
|
|
var rangeStart = from ?? rangeEnd.AddDays(-30);
|
|
|
|
var trends = await _trends.GetAsync(challengeId, rangeStart, rangeEnd, cancellationToken);
|
|
|
|
return Ok(trends);
|
|
}
|
|
}
|