Fix category feeds not selecting child category posts

This commit is contained in:
Daniel J. Summers 2022-06-01 07:45:13 -04:00
parent 39fdf42827
commit c377496611
2 changed files with 8 additions and 5 deletions

View File

@ -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
}

View File

@ -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"