Resolve "Feature: Show completion" #74

Merged
thorsten merged 9 commits from 28-feature-show-completion into main 2022-09-26 20:09:55 +00:00
Showing only changes of commit c8b5dc9b7a - Show all commits

View File

@ -51,4 +51,15 @@ public static class TranslationProcessor
return updateException.ToProcessorResult<Translation>();
}
}
public static async Task<ProcessorResult<int>> CalculateTranslationProgress()
{
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
var numCultures = (await AppSettings.GetCultureIndices()).Count;
var numTextElements = await db.TextElements.CountAsync();
var numTotalTranslations = numCultures * numTextElements;
var numTextElementsTranslated = await db.Translations.CountAsync(n => !string.IsNullOrWhiteSpace(n.Text));
return new ProcessorResult<int>(numTextElementsTranslated * 100 / numTotalTranslations);
}
}