lazy-create batches

This commit is contained in:
Collin M. Barrett 2018-08-25 09:46:14 -05:00
parent 75a37df108
commit d9fd73ccb3

View file

@ -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()