refactor(dotnet): normalize learning dataset export inputs
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 19s
Validators (Pushes and Pull Requests) / validate-core (push) Failing after 1m42s

This commit is contained in:
2026-07-13 01:30:42 +09:00
parent c20cbc982b
commit 26e5f5a024
2 changed files with 68 additions and 2 deletions
@@ -11,7 +11,9 @@ public sealed class LearningDatasetService
public async Task<string> ExportJsonAsync(string outputPath, int limit = 1000)
{
var rows = await _reader.ReadTrainingExamplesAsync(limit);
var normalizedOutputPath = RequireValue(outputPath, nameof(outputPath));
var normalizedLimit = Math.Clamp(limit, 1, 10000);
var rows = await _reader.ReadTrainingExamplesAsync(normalizedLimit);
var payload = new
{
formula_id = "ENGINE_HISTORY_TRAINING_DATASET_V1",
@@ -21,9 +23,19 @@ public sealed class LearningDatasetService
source = "engine_history.training_example_v1",
rows
};
var path = Path.GetFullPath(outputPath);
var path = Path.GetFullPath(normalizedOutputPath);
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
await File.WriteAllTextAsync(path, JsonSerializer.Serialize(payload, new JsonSerializerOptions { WriteIndented = true }));
return path;
}
private static string RequireValue(string value, string parameterName)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Value is required.", parameterName);
}
return value.Trim();
}
}