Files
GmRelayBot/src/GmRelay.Web/Services/BatchSchedulePlanner.cs
T
Toutsu a8f2b10956
Deploy Telegram Bot / build-and-push (push) Successful in 3m36s
Deploy Telegram Bot / deploy (push) Successful in 11s
feat: send personal player notifications
2026-04-27 10:11:11 +03:00

47 lines
1.4 KiB
C#

using GmRelay.Shared.Domain;
namespace GmRelay.Web.Services;
public enum BatchCloneInterval
{
NextWeek,
NextMonth
}
public sealed record WebSessionBatch(
Guid Id,
Guid GroupId,
string Title,
string JoinLink,
DateTime FirstScheduledAt,
DateTime LastScheduledAt,
int SessionCount,
string NotificationMode = SessionNotificationModeExtensions.GroupAndDirectValue);
public static class BatchSchedulePlanner
{
public static IReadOnlyList<DateTime> BuildFixedIntervalSchedule(
IEnumerable<DateTime> currentSchedule,
DateTime firstScheduledAt,
int intervalDays)
{
if (intervalDays <= 0)
{
throw new ArgumentOutOfRangeException(nameof(intervalDays), intervalDays, "Interval must be greater than zero.");
}
return currentSchedule
.OrderBy(scheduledAt => scheduledAt)
.Select((_, index) => firstScheduledAt.AddDays(intervalDays * index))
.ToList();
}
public static DateTime ShiftForClone(DateTime scheduledAt, BatchCloneInterval interval) =>
interval switch
{
BatchCloneInterval.NextWeek => scheduledAt.AddDays(7),
BatchCloneInterval.NextMonth => scheduledAt.AddMonths(1),
_ => throw new ArgumentOutOfRangeException(nameof(interval), interval, "Unknown clone interval.")
};
}