From 610f9e2b22f1d6b58efc303dde3fa30a985276e2 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 11 Jan 2021 23:06:59 +0900 Subject: [PATCH] Log text search migration progress --- BTCPayServer/HostedServices/DbMigrationsHostedService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/HostedServices/DbMigrationsHostedService.cs b/BTCPayServer/HostedServices/DbMigrationsHostedService.cs index 225d98e2b..76850f2be 100644 --- a/BTCPayServer/HostedServices/DbMigrationsHostedService.cs +++ b/BTCPayServer/HostedServices/DbMigrationsHostedService.cs @@ -5,9 +5,11 @@ using System.IO; using System.Threading.Tasks; using BTCPayServer.Configuration; using BTCPayServer.Data; +using BTCPayServer.Logging; using BTCPayServer.Services; using BTCPayServer.Services.Invoices; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Logging; namespace BTCPayServer.HostedServices { @@ -54,16 +56,17 @@ namespace BTCPayServer.HostedServices { Directory.Delete(dbpath, true); } - - // migrate data to new table using invoices from database - using var ctx = _dbContextFactory.CreateContext(); var invoiceQuery = new InvoiceQuery { IncludeArchived = true }; var totalCount = await _invoiceRepository.GetInvoicesTotal(invoiceQuery); const int PAGE_SIZE = 1000; var totalPages = Math.Ceiling(totalCount * 1.0m / PAGE_SIZE); + Logs.PayServer.LogInformation($"Importing {totalCount} invoices into the text search table in {totalPages - startFromPage} pages"); for (int i = startFromPage; i < totalPages && !CancellationToken.IsCancellationRequested; i++) { + Logs.PayServer.LogInformation($"Import to text search table progress: {i}/{totalPages} pages"); + // migrate data to new table using invoices from database + using var ctx = _dbContextFactory.CreateContext(); invoiceQuery.Skip = i * PAGE_SIZE; invoiceQuery.Take = PAGE_SIZE; var invoices = await _invoiceRepository.GetInvoices(invoiceQuery);