feat: export PostgreSQL training dataset as JSON
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Failing after 17s
Validators (Pushes and Pull Requests) / validate-core (push) Failing after 54s

This commit is contained in:
2026-07-12 11:55:17 +09:00
parent e15e4c6e20
commit 49637f1b02
4 changed files with 61 additions and 0 deletions
@@ -0,0 +1,24 @@
using Dapper;
using QuantEngine.Core.Interfaces;
using QuantEngine.Infrastructure.Data;
namespace QuantEngine.Infrastructure.Repositories;
public sealed class LearningDatasetReader : ILearningDatasetReader
{
private readonly IDbConnectionFactory _connectionFactory;
public LearningDatasetReader(IDbConnectionFactory connectionFactory) => _connectionFactory = connectionFactory;
public async Task<IReadOnlyList<IDictionary<string, object?>>> ReadTrainingExamplesAsync(int limit = 1000)
{
if (limit is < 1 or > 10000)
throw new ArgumentOutOfRangeException(nameof(limit));
using var connection = _connectionFactory.CreateConnection();
var rows = await connection.QueryAsync(
"SELECT * FROM engine_history.training_example_v1 ORDER BY decided_at DESC LIMIT @Limit",
new { Limit = limit });
return rows.Select(row => (IDictionary<string, object?>)row).ToList();
}
}