Refactor components to enhance code clarity and maintainability by updating prop types to use Readonly for better immutability. Adjust Result class methods for consistency, and streamline query functions in ChannelDetail and other components to improve performance and readability.
ci / build-backend (push) Successful in 1m41s
ci / build-frontend (push) Successful in 47s
ci / sonar (push) Successful in 5m35s
ci / tests (push) Successful in 2m40s

This commit is contained in:
Leonid Pershin committed 2026-07-27 01:14:53 +03:00
1 parent ecb5417170
commit 5449c05b5b
56 files changed
+132 -124

No files matched your search

@@ -18,10 +18,10 @@ public class Result
public static Result Success() => new(true, Error.None);
public static Result Failure(Error error) => new(false, error);
public static Result<T> Success<T>(T value) => new(value, true, Error.None);
public static Result Failure(Error error) => new(false, error);
public static Result<T> Failure<T>(Error error) => new(default, false, error);
}
@@ -195,7 +195,7 @@ public sealed class GroupExpander(IAppDbContext dbContext)
e.ChannelId == channelId
&& e.Kind == ScheduleEntryKind.Program
&& e.ShowId != null
&& showIds.Contains(e.ShowId!.Value)
&& showIds.Contains(e.ShowId.Value)
)
.GroupBy(e => e.ShowId!.Value)
.Select(g => new { ShowId = g.Key, LastPlayed = g.Max(e => e.StartsAtUtc) })
@@ -221,7 +221,7 @@ public sealed class GroupExpander(IAppDbContext dbContext)
e.ChannelId == channelId
&& e.Kind == ScheduleEntryKind.Program
&& e.ShowId != null
&& showIds.Contains(e.ShowId!.Value)
&& showIds.Contains(e.ShowId.Value)
&& e.StartsAtUtc >= since
)
.Select(e => new { ShowId = e.ShowId!.Value, e.StartsAtUtc })
@@ -50,12 +50,8 @@ public sealed record PlanningRules(
// Пересекающиеся окна разрешаются в пользу строгого: детское время не должно
// отменяться более широким окном, случайно наложенным сверху.
ShowAudience? strictest = null;
foreach (var window in windows.Where(w => w.Contains(moment)))
strictest = strictest is { } current && current <= window.MaxAudience
? current
: window.MaxAudience;
return strictest;
var applicable = windows.Where(w => w.Contains(moment)).Select(w => w.MaxAudience).ToList();
return applicable.Count > 0 ? applicable.Min() : null;
}
public string ToJson() => JsonSerializer.Serialize(this, Options);
@@ -110,7 +110,7 @@ internal sealed class RoleService(
if (currentRoles.Count > 0)
await userManager.RemoveFromRolesAsync(user, currentRoles);
await userManager.AddToRoleAsync(user, role.Name!);
await userManager.AddToRoleAsync(user, role.Name);
return Result.Success();
}