feat: add web batch bulk operations
Deploy Telegram Bot / build-and-push (push) Successful in 3m21s
Deploy Telegram Bot / deploy (push) Successful in 11s

This commit is contained in:
2026-04-27 09:31:51 +03:00
parent 5f3516e703
commit 621ef553e7
12 changed files with 931 additions and 7 deletions
@@ -0,0 +1,43 @@
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);
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.")
};
}