yavsc/src/Yavsc.Server/Settings/ResourceUsageOptions.cs
Paul Schneider 650e5f5e30
feat: add resource quotas, PayPal subscriptions and paid disk allowances
Calculate and enforce configurable resource consumption, expose balances in PostIt and document the rule in CGU. Add confirmed monthly PayPal credits and disk quotas of twice the free default for Discovery and five times for Premium, with payment reconciliation, migrations and regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-08 05:02:23 +00:00

21 lines
879 B
C#

#nullable enable
namespace Yavsc.Settings;
public sealed class ResourceUsageOptions
{
public const string SectionName = "ResourceUsage";
public decimal ApiCallWeight { get; set; } = 0.2m;
public decimal CpuSecondWeight { get; set; } = 0.1m;
public decimal BandwidthMbWeight { get; set; } = 0.05m;
public decimal StorageMbWeight { get; set; } = 0.5m;
public decimal DefaultLimit { get; set; } = 1000m;
public Dictionary<string, decimal> UserLimits { get; set; } = new();
public decimal GetLimit(string userId)
=> UserLimits.TryGetValue(userId, out var limit) ? limit : DefaultLimit;
public decimal Calculate(decimal apiCalls, decimal cpuSeconds, decimal bandwidthMb, decimal storageMb)
=> apiCalls * ApiCallWeight + cpuSeconds * CpuSecondWeight
+ bandwidthMb * BandwidthMbWeight + storageMb * StorageMbWeight;
}