mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(archival): ✨⚡ equally space archival jobs throughout the day to distribute resources
This commit is contained in:
parent
eed80de6d2
commit
7f0ee525a2
1 changed files with 4 additions and 1 deletions
|
|
@ -29,15 +29,18 @@ public async Task<Unit> Handle(Command request, CancellationToken cancellationTo
|
|||
var lists = (await _directory.GetListsAsync(cancellationToken)).OrderBy(_ => r.Next()).ToList();
|
||||
|
||||
int numToArchive;
|
||||
TimeSpan spacing;
|
||||
#if DEBUG
|
||||
numToArchive = 25;
|
||||
spacing = TimeSpan.FromSeconds(2.5);
|
||||
#else
|
||||
numToArchive = lists.Count;
|
||||
spacing = TimeSpan.FromSeconds((double)86400 / lists.Count);
|
||||
#endif
|
||||
|
||||
for (var i = 0; i < numToArchive; i++)
|
||||
{
|
||||
new ArchiveList.Command(lists[i].Id).EnqueueBackgroundJob();
|
||||
new ArchiveList.Command(lists[i].Id).ScheduleBackgroundJob(i * spacing);
|
||||
}
|
||||
|
||||
return Unit.Value;
|
||||
|
|
|
|||
Loading…
Reference in a new issue