From c37749661150ddfec2d4312c8583b981c62a4d7e Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Wed, 1 Jun 2022 07:45:13 -0400 Subject: [PATCH] Fix category feeds not selecting child category posts --- src/MyWebLog/Handlers/Feed.fs | 11 +++++++---- src/MyWebLog/appsettings.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/MyWebLog/Handlers/Feed.fs b/src/MyWebLog/Handlers/Feed.fs index cfc5b35..4e03d96 100644 --- a/src/MyWebLog/Handlers/Feed.fs +++ b/src/MyWebLog/Handlers/Feed.fs @@ -45,14 +45,17 @@ let deriveFeedType (ctx : HttpContext) feedPath : (FeedType * int) option = None /// Determine the function to retrieve posts for the given feed -let private getFeedPosts (webLog : WebLog) feedType = +let private getFeedPosts (webLog : WebLog) feedType ctx = + let childIds catId = + let cat = CategoryCache.get ctx |> Array.find (fun c -> c.id = CategoryId.toString catId) + getCategoryIds cat.slug ctx match feedType with | StandardFeed _ -> Data.Post.findPageOfPublishedPosts webLog.id 1 - | CategoryFeed (catId, _) -> Data.Post.findPageOfCategorizedPosts webLog.id [ catId ] 1 + | CategoryFeed (catId, _) -> Data.Post.findPageOfCategorizedPosts webLog.id (childIds catId) 1 | TagFeed (tag, _) -> Data.Post.findPageOfTaggedPosts webLog.id tag 1 | Custom (feed, _) -> match feed.source with - | Category catId -> Data.Post.findPageOfCategorizedPosts webLog.id [ catId ] 1 + | Category catId -> Data.Post.findPageOfCategorizedPosts webLog.id (childIds catId) 1 | Tag tag -> Data.Post.findPageOfTaggedPosts webLog.id tag 1 /// Strip HTML from a string @@ -319,7 +322,7 @@ let createFeed (feedType : FeedType) posts : HttpHandler = fun next ctx -> backg // GET {any-prescribed-feed} let generate (feedType : FeedType) postCount : HttpHandler = fun next ctx -> backgroundTask { - match! getFeedPosts ctx.WebLog feedType postCount ctx.Conn with + match! getFeedPosts ctx.WebLog feedType ctx postCount ctx.Conn with | posts when List.length posts > 0 -> return! createFeed feedType posts next ctx | _ -> return! Error.notFound next ctx } diff --git a/src/MyWebLog/appsettings.json b/src/MyWebLog/appsettings.json index 1d37576..70d56c7 100644 --- a/src/MyWebLog/appsettings.json +++ b/src/MyWebLog/appsettings.json @@ -3,7 +3,7 @@ "hostname": "data02.bitbadger.solutions", "database": "myWebLog_dev" }, - "Generator": "myWebLog 2.0-alpha23", + "Generator": "myWebLog 2.0-alpha24", "Logging": { "LogLevel": { "MyWebLog.Handlers": "Debug"