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> 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>(0) ?? []; return rows .Select(row => new SocialChallengeResponse(row.Id, row.Name, row.Description, row.Order)) .ToList(); } }