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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user