Fase 11 — Decisioni solo matematiche (#186)
ci / test (postgres) (push) Successful in 7m36s
ci / test (sqlite) (push) Successful in 6m41s
ci / image (push) Successful in 1m49s

News, the economic calendar and earnings dates no longer change any decision (ADR 0023, choices in ADR 0027). The outside rules are measured in the shadow; a switch in the settings turns them back on.

refs #116, refs #117

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #186.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-12-04 09:14:11 +01:00
1 parent ed22d1c8b5
commit 93cdf7850d
47 files changed
+1743 -169

No files matched your search

+40 -2
View File
@@ -272,17 +272,23 @@ internal static partial class Forms
var back = Back(form, "/impostazioni");
var news = Anubis.News.NewsRuleSettings.All.Any(d => d.Key == key);
var model = Anubis.News.NewsModelSettings.All.Any(d => d.Key == key);
var rules = key == Anubis.News.ExternalRules.Setting.Key;
if (key != SettingsStore.Theme.Key && key != SettingsStore.Currency.Key && key != SettingsStore.CentralBankMeetings.Key && key != SettingsStore.TelegramStatus.Key && key != Anubis.Trading.TaxExport.MethodSetting.Key &&
!news && !model)
!news && !model && !rules)
{
return Results.Redirect(With(back, "errore", "impostazione"));
}
if ((news || model) && host.IsDemo)
if ((news || model || rules) && host.IsDemo)
{
return Results.Redirect(With(back, "errore", "motore"));
}
if (rules && host.Services is { } services0)
{
return Results.Redirect(await ExternalRulesAsync(services0, clock, form, context, ct).ConfigureAwait(false) is { } problem ? With(back, "errore", problem) : back);
}
if (model)
{
// Amounts as the user writes them, "0,50" or "0,50 €", stored as "0.50"; the other values trimmed.
@@ -327,6 +333,38 @@ internal static partial class Forms
return Results.Redirect(result is IStatusCodeHttpResult { StatusCode: StatusCodes.Status204NoContent } ? back : With(back, "errore", "impostazione"));
}
/// <summary>
/// The general switch of ADR 0023 (ADR 0027 points 4 and 5): only measuring the rules takes restrictions away, so with
/// real money it asks for the phrase and the password, as switching a row off; acting again is free. A real change
/// writes its diary line in the same transaction. Null when saved, otherwise the error code of the page.
/// </summary>
private static async Task<string?> ExternalRulesAsync(AppServices app, IClock clock, IFormCollection form, HttpContext context, CancellationToken ct)
{
var value = form["valore"].ToString();
if (value is not (Anubis.News.ExternalRules.Measured or Anubis.News.ExternalRules.Active))
{
return "impostazione";
}
var key = Anubis.News.ExternalRules.Setting.Key;
if (value == Anubis.News.ExternalRules.Measured && (await app.Settings.GetAsync(key, ct).ConfigureAwait(false)).Value != Anubis.News.ExternalRules.Measured &&
await RaiseRefusalAsync(app, clock, null, form, ct).ConfigureAwait(false) is { } refusal)
{
return refusal;
}
var by = context.User.Identity?.Name ?? "utente";
try
{
await app.Settings.SetAsync(key, value, by, (s, old) => Anubis.News.ExternalRules.WriteChangeAsync(s, clock, old, value, by, ct), ct).ConfigureAwait(false);
return null;
}
catch (ReadOnlySettingException)
{
return "impostazione";
}
}
private static async Task<IResult> BotAsync(string command, IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct)
{
var back = Back(form, "/");