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.
30 lines
926 B
C#
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();
|
|
}
|
|
}
|