2 Commits

Author SHA1 Message Date
Tommy Parnell
2a1f34d81c stop 2019-02-08 00:45:43 -05:00
Tommy Parnell
e539263aa4 stop 2019-02-08 00:33:57 -05:00
4 changed files with 8 additions and 10 deletions

View File

@@ -15,16 +15,9 @@ namespace TerribleDev.Blog.Web.Factories
.Aggregate( .Aggregate(
ImmutableDictionary.Create<string, ImmutableList<IPost>>(), ImmutableDictionary.Create<string, ImmutableList<IPost>>(),
(accum, item) => { (accum, item) => {
foreach(var tag in item.tags.Select(i => i.ToLower())) foreach(var tag in item.tags.Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => i.ToLower()))
{ {
if(accum.TryGetValue(tag, out var list)) accum = accum.TryGetValue(tag, out var list) ? accum.SetItem(tag, list.Add(item)) : accum.Add(tag, ImmutableList.Create(item));
{
accum = accum.SetItem(tag, list.Add(item));
}
else
{
accum = accum.Add(tag, ImmutableList.Create<IPost>(item));
}
} }
return accum; return accum;
}).ToImmutableSortedDictionary(); }).ToImmutableSortedDictionary();
@@ -46,6 +39,7 @@ namespace TerribleDev.Blog.Web.Factories
return accum.SetItem(highestPage, current.Add(item)); return accum.SetItem(highestPage, current.Add(item));
}).ToImmutableDictionary(); }).ToImmutableDictionary();
var syndicationPosts = posts.Select(i => i.ToSyndicationItem()).ToImmutableList(); var syndicationPosts = posts.Select(i => i.ToSyndicationItem()).ToImmutableList();
var postsToPosition = posts.Select((item, index) => (item, index)).ToImmutableDictionary(i => i.item, i => i.index);
return new PostCache() return new PostCache()
{ {
PostsAsLists = posts, PostsAsLists = posts,

View File

@@ -18,5 +18,7 @@ namespace TerribleDev.Blog.Web.Models
public string SummaryPlainShort { get; set; } public string SummaryPlainShort { get; set; }
public IList<string> tags { get; set; } public IList<string> tags { get; set; }
public IList<string> Images { get; set;} public IList<string> Images { get; set;}
} }
} }

View File

@@ -10,6 +10,7 @@ namespace TerribleDev.Blog.Web.Models
public ImmutableDictionary<string, IPost> UrlToPost { get; set; } public ImmutableDictionary<string, IPost> UrlToPost { get; set; }
public ImmutableDictionary<int, ImmutableList<IPost>> PostsByPage { get; set; } public ImmutableDictionary<int, ImmutableList<IPost>> PostsByPage { get; set; }
public ImmutableList<SyndicationItem> PostsAsSyndication { get; set; } public ImmutableList<SyndicationItem> PostsAsSyndication { get; set; }
public ImmutableDictionary<IPost, int> PostToPosition { get; set; }
} }
} }

View File

@@ -7,6 +7,7 @@
<UserSecretsId>9a1f51b6-f4d9-4df7-a0af-e345176e9927</UserSecretsId> <UserSecretsId>9a1f51b6-f4d9-4df7-a0af-e345176e9927</UserSecretsId>
<ApplicationInsightsResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsResourceId> <ApplicationInsightsResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsAnnotationResourceId> <ApplicationInsightsAnnotationResourceId>/subscriptions/088a81c7-d703-41c9-a1d0-476bce11df60/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/tparnellblognew</ApplicationInsightsAnnotationResourceId>
<LangVersion>7.3</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>