mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
lazy-create batches
This commit is contained in:
parent
75a37df108
commit
d9fd73ccb3
1 changed files with 5 additions and 13 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
|
@ -120,21 +119,14 @@ private async Task GetLines()
|
|||
}
|
||||
|
||||
private async Task SaveInBatches()
|
||||
{
|
||||
var snapBatches = await CreateBatches();
|
||||
SaveBatches(snapBatches);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<Batch>> CreateBatches()
|
||||
{
|
||||
SnapEntity.BatchSize = await batchSizeService.GetBatchSize();
|
||||
return lines.Batch(SnapEntity.BatchSize.Value).Select(b => new Batch(dbContext, b, SnapEntity));
|
||||
}
|
||||
|
||||
private static void SaveBatches(IEnumerable<Batch> batches)
|
||||
{
|
||||
foreach (var batch in batches)
|
||||
var lineBatches = lines.Batch(SnapEntity.BatchSize.Value);
|
||||
foreach (var lineBatch in lineBatches)
|
||||
{
|
||||
var batch = new Batch(dbContext, lineBatch, SnapEntity);
|
||||
batch.Save();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SetSuccessful()
|
||||
|
|
|
|||
Loading…
Reference in a new issue