Skip to content

Commit

Permalink
remove fetching siteparts memo
Browse files Browse the repository at this point in the history
  • Loading branch information
iwate committed Mar 29, 2024
1 parent feded58 commit 57a6b1f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions templates/Modd/Shared/Functions.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,23 @@
var root = Href("~/");
var cacheKey = globalCacheKey("SiteParts");
var siteParts = Page.Template.Cache(cacheKey, NextLongLong, () =>
Database.Query(Now, db => db.SiteParts)
.Select(p => new KeyValuePair<Regex, SiteParts>(new Regex(("^" + root + p.Pattern + "$").Replace("//","/"), RegexOptions.IgnoreCase), p)));
Database.Query(new { Now, IsPreview }, db =>
db.SiteParts.Where(p => p.Html != null).Select(p => new {
Pattern = p.Pattern,
Position = p.Position,
DisplayOrder = p.DisplayOrder,
Html = p.Html,
})
)
.Select(p => {
return new KeyValuePair<Regex, SiteParts>(new Regex(("^" + root + p.Pattern + "$").Replace("//","/"), RegexOptions.IgnoreCase), new SiteParts
{
Pattern = p.Pattern,
Position = p.Position,
DisplayOrder = p.DisplayOrder,
Html = p.Html,
});
}));

var path = Page.Request.Url.AbsolutePath;
if (root.Equals(path + "/", StringComparison.OrdinalIgnoreCase)) {
Expand Down

0 comments on commit 57a6b1f

Please sign in to comment.