Add tests through post curr permalink

- Resolve SQLite / RethinkDB env refresh hiccups
This commit is contained in:
2024-01-30 22:45:33 -05:00
parent 78c1c5e68e
commit 24d49e26e5
12 changed files with 298 additions and 57 deletions

View File

@@ -94,10 +94,13 @@ type PostgresPageData(log: ILogger) =
}
/// Find a page by its permalink for the given web log
let findByPermalink (permalink: Permalink) webLogId =
let findByPermalink (permalink: Permalink) webLogId = backgroundTask {
log.LogTrace "Page.findByPermalink"
Find.byContains<Page> Table.Page {| webLogDoc webLogId with Permalink = permalink |}
|> tryHead
let! page =
Find.byContains<Page> Table.Page {| webLogDoc webLogId with Permalink = permalink |}
|> tryHead
return page |> Option.map (fun pg -> { pg with PriorPermalinks = [] })
}
/// Find the current permalink within a set of potential prior permalinks for the given web log
let findCurrentPermalink (permalinks: Permalink list) webLogId = backgroundTask {

View File

@@ -42,9 +42,12 @@ type PostgresPostData(log: ILogger) =
Count.byContains Table.Post {| webLogDoc webLogId with Status = status |}
/// Find a post by its ID for the given web log (excluding revisions)
let findById postId webLogId =
let findById postId webLogId = backgroundTask {
log.LogTrace "Post.findById"
Document.findByIdAndWebLog<PostId, Post> Table.Post postId webLogId
match! Document.findByIdAndWebLog<PostId, Post> Table.Post postId webLogId with
| Some post -> return Some { post with PriorPermalinks = [] }
| None -> return None
}
/// Find a post by its permalink for the given web log (excluding revisions)
let findByPermalink (permalink: Permalink) webLogId =
@@ -52,12 +55,12 @@ type PostgresPostData(log: ILogger) =
Custom.single
(selectWithCriteria Table.Post)
[ jsonParam "@criteria" {| webLogDoc webLogId with Permalink = permalink |} ]
fromData<Post>
(fun row -> { fromData<Post> row with PriorPermalinks = [] })
/// Find a complete post by its ID for the given web log
let findFullById postId webLogId = backgroundTask {
log.LogTrace "Post.findFullById"
match! findById postId webLogId with
match! Document.findByIdAndWebLog<PostId, Post> Table.Post postId webLogId with
| Some post ->
let! withRevisions = appendPostRevisions post
return Some withRevisions