refactor(dotnet): normalize workspace and approval inputs
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 18s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled

This commit is contained in:
2026-07-13 01:29:26 +09:00
parent cb814b8aa2
commit c20cbc982b
3 changed files with 103 additions and 24 deletions
@@ -11,22 +11,39 @@ namespace QuantEngine.Application.Services
private readonly IWorkspaceRepository _repository;
private readonly IPostgresqlHistoryStore _historyStore;
public WorkspaceService(IWorkspaceRepository repository, IPostgresqlHistoryStore historyStore)
public WorkspaceService(IWorkspaceRepository repository, IPostgresqlHistoryStore historyStore)
{
_repository = repository;
_historyStore = historyStore;
}
public Task<IEnumerable<Setting>> GetSettingsAsync() => _repository.GetSettingsAsync();
public Task<Setting?> GetSettingByKeyAsync(string key) => _repository.GetSettingByKeyAsync(RequireValue(key, nameof(key)));
public Task<bool> UpsertSettingAsync(Setting setting)
{
ArgumentNullException.ThrowIfNull(setting);
return _repository.UpsertSettingAsync(setting);
}
public Task<bool> DeleteSettingAsync(string key) => _repository.DeleteSettingAsync(RequireValue(key, nameof(key)));
public Task<IEnumerable<AccountSnapshot>> GetAccountSnapshotsAsync() => _repository.GetAccountSnapshotsAsync();
public Task<bool> InsertAccountSnapshotsAsync(IEnumerable<AccountSnapshot> snapshots) => _repository.InsertAccountSnapshotsAsync(snapshots);
public Task<bool> ClearAccountSnapshotsAsync() => _repository.ClearAccountSnapshotsAsync();
public Task<int> AppendHistoryAsync(string domain, IDictionary<string, object?> payload)
=> _historyStore.AppendAsync(RequireValue(domain, nameof(domain)), payload);
public Task<IReadOnlyList<IDictionary<string, object?>>> ReadHistorySnapshotAsync(string domain, int limit = 500)
=> _historyStore.SnapshotAsync(RequireValue(domain, nameof(domain)), Math.Clamp(limit, 1, 2000));
private static string RequireValue(string value, string parameterName)
{
if (string.IsNullOrWhiteSpace(value))
{
_repository = repository;
_historyStore = historyStore;
throw new ArgumentException("Value is required.", parameterName);
}
public Task<IEnumerable<Setting>> GetSettingsAsync() => _repository.GetSettingsAsync();
public Task<Setting?> GetSettingByKeyAsync(string key) => _repository.GetSettingByKeyAsync(key);
public Task<bool> UpsertSettingAsync(Setting setting) => _repository.UpsertSettingAsync(setting);
public Task<bool> DeleteSettingAsync(string key) => _repository.DeleteSettingAsync(key);
public Task<IEnumerable<AccountSnapshot>> GetAccountSnapshotsAsync() => _repository.GetAccountSnapshotsAsync();
public Task<bool> InsertAccountSnapshotsAsync(IEnumerable<AccountSnapshot> snapshots) => _repository.InsertAccountSnapshotsAsync(snapshots);
public Task<bool> ClearAccountSnapshotsAsync() => _repository.ClearAccountSnapshotsAsync();
public Task<int> AppendHistoryAsync(string domain, IDictionary<string, object?> payload) => _historyStore.AppendAsync(domain, payload);
public Task<IReadOnlyList<IDictionary<string, object?>>> ReadHistorySnapshotAsync(string domain, int limit = 500) => _historyStore.SnapshotAsync(domain, limit);
return value.Trim();
}
}
}