Refactor authentication and streaming cookie handling: implement secure cookie logic based on environment in AuthEndpoints and StreamingEndpoints, enhance rate limiting policy in Program.cs, and update logging configuration in appsettings.json. Fix validation behavior to use asynchronous validation methods and improve error handling in frontend components.
build / backend (push) Successful in 1m52s
build / frontend (push) Successful in 1m0s
tests / backend-tests (push) Successful in 2m27s

This commit is contained in:
Leonid Pershin
2026-07-25 21:18:31 +03:00
parent 53e0eeb776
commit 058cbc6994
15 changed files with 282 additions and 99 deletions
@@ -195,12 +195,12 @@ public static class SchedulePlanner
IRandomSource random
)
{
var total = eligible.Sum(v => Math.Max(0, v.Weight));
var total = eligible.Sum(v => (long)Math.Max(0, v.Weight));
if (total <= 0)
return eligible[random.Next(eligible.Count)];
var roll = random.Next(total);
var acc = 0;
var roll = random.Next((int)Math.Min(total, int.MaxValue));
long acc = 0;
foreach (var v in eligible)
{
acc += Math.Max(0, v.Weight);
@@ -253,7 +253,9 @@ public static class SchedulePlanner
&& show.PreferredHours is { Count: > 0 } windows
&& windows.Any(w => w.Contains(hour))
)
return show.Weight * show.PreferredWeightMultiplier;
// long-умножение + clamp: экстремальные вес/множитель не переполняют int
// (иначе отрицательный total молча вырождает взвешенный выбор в первого кандидата).
return (int)Math.Min((long)show.Weight * show.PreferredWeightMultiplier, int.MaxValue);
return show.Weight;
}
@@ -262,12 +264,12 @@ public static class SchedulePlanner
IRandomSource random
)
{
var total = candidates.Sum(c => c.Weight);
var total = candidates.Sum(c => (long)c.Weight);
if (total <= 0)
return candidates[0].Show;
var roll = random.Next(total);
var acc = 0;
var roll = random.Next((int)Math.Min(total, int.MaxValue));
long acc = 0;
foreach (var (show, weight) in candidates)
{
acc += weight;