Files
Rafał Tyński bad37a6ab9 feat(backend): add knowledge base, innovation library and trends modules
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.
2026-10-04 02:32:33 +02:00

30 lines
926 B
C#

using SurrealDb.Net;
using TarninaHub.Application.Abstractions;
using TarninaHub.Application.Dtos;
namespace TarninaHub.Infrastructure.Persistence;
public sealed class ChallengeService : IChallengeService
{
private readonly ISurrealDbClient _client;
public ChallengeService(ISurrealDbClient client)
{
_client = client;
}
public async Task<IReadOnlyList<SocialChallengeResponse>> ListAsync(CancellationToken cancellationToken)
{
var response = await _client.RawQuery(
"SELECT type::string(id) AS id, name, description, order FROM social_challenge ORDER BY order;",
cancellationToken: cancellationToken);
response.EnsureAllOks();
var rows = response.GetValue<List<ChallengeRow>>(0) ?? [];
return rows
.Select(row => new SocialChallengeResponse(row.Id, row.Name, row.Description, row.Order))
.ToList();
}
}