mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(archival): ✨ in DEBUG, archive only 25 lists and on startup
This commit is contained in:
parent
92cc505faa
commit
cee379cf9f
2 changed files with 16 additions and 2 deletions
|
|
@ -26,9 +26,18 @@ public Handler(IDirectoryApi directory)
|
|||
public async Task<Unit> Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
var r = new Random();
|
||||
foreach (var list in (await _directory.GetListsAsync(cancellationToken)).OrderBy(_ => r.Next()))
|
||||
var lists = (await _directory.GetListsAsync(cancellationToken)).OrderBy(_ => r.Next()).ToList();
|
||||
|
||||
int numToArchive;
|
||||
#if DEBUG
|
||||
numToArchive = 25;
|
||||
#else
|
||||
numToArchive = lists.Count;
|
||||
#endif
|
||||
|
||||
for (var i = 0; i < numToArchive; i++)
|
||||
{
|
||||
new ArchiveList.Command(list.Id).EnqueueBackgroundJob();
|
||||
new ArchiveList.Command(lists[i].Id).EnqueueBackgroundJob();
|
||||
}
|
||||
|
||||
return Unit.Value;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,12 @@ public static void UseApplication(this IApplicationBuilder app)
|
|||
private static void ScheduleArchival(this IApplicationBuilder app)
|
||||
{
|
||||
_ = app ?? throw new ArgumentNullException(nameof(app));
|
||||
|
||||
#if DEBUG
|
||||
new EnqueueArchiveAllLists.Command().EnqueueBackgroundJob();
|
||||
#else
|
||||
new EnqueueArchiveAllLists.Command().AddOrUpdateRecurringJob(Cron.Daily);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue