Merge pull request #660 from sbwalker/master
optimize NotificationJob so that it only processes the sites for each tenant once.
This commit is contained in:
@ -20,11 +20,15 @@ namespace Oqtane.Infrastructure
|
|||||||
{
|
{
|
||||||
string log = "";
|
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>();
|
var aliasRepository = provider.GetRequiredService<IAliasRepository>();
|
||||||
List<Alias> aliases = aliasRepository.GetAliases().ToList();
|
List<Alias> aliases = aliasRepository.GetAliases().ToList();
|
||||||
foreach (Alias alias in aliases)
|
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
|
// use the SiteState to set the Alias explicitly so the tenant can be resolved
|
||||||
var siteState = provider.GetRequiredService<SiteState>();
|
var siteState = provider.GetRequiredService<SiteState>();
|
||||||
siteState.Alias = alias;
|
siteState.Alias = alias;
|
||||||
@ -34,7 +38,7 @@ namespace Oqtane.Infrastructure
|
|||||||
var settingRepository = provider.GetRequiredService<ISettingRepository>();
|
var settingRepository = provider.GetRequiredService<ISettingRepository>();
|
||||||
var notificationRepository = provider.GetRequiredService<INotificationRepository>();
|
var notificationRepository = provider.GetRequiredService<INotificationRepository>();
|
||||||
|
|
||||||
// iterate through sites
|
// iterate through sites for this tenant
|
||||||
List<Site> sites = siteRepository.GetSites().ToList();
|
List<Site> sites = siteRepository.GetSites().ToList();
|
||||||
foreach (Site site in sites)
|
foreach (Site site in sites)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user