optimize NotificationJob so that it only processes the sites for each tenant once.

This commit is contained in:
Shaun Walker 2020-07-23 14:14:29 -04:00
parent 3a6cde0e24
commit 75fe4e7c89

View File

@ -20,11 +20,15 @@ namespace Oqtane.Infrastructure
{
string log = "";
// iterate through aliases in this installation
// iterate through tenants in this installation
List<int> tenants = new List<int>();
var aliasRepository = provider.GetRequiredService<IAliasRepository>();
List<Alias> aliases = aliasRepository.GetAliases().ToList();
foreach (Alias alias in aliases)
{
if (tenants.Contains(alias.TenantId)) continue;
tenants.Add(alias.TenantId);
// use the SiteState to set the Alias explicitly so the tenant can be resolved
var siteState = provider.GetRequiredService<SiteState>();
siteState.Alias = alias;
@ -34,7 +38,7 @@ namespace Oqtane.Infrastructure
var settingRepository = provider.GetRequiredService<ISettingRepository>();
var notificationRepository = provider.GetRequiredService<INotificationRepository>();
// iterate through sites
// iterate through sites for this tenant
List<Site> sites = siteRepository.GetSites().ToList();
foreach (Site site in sites)
{