refactor
This commit is contained in:
parent
190d086206
commit
ce7bb9d386
9 changed files with 442 additions and 500 deletions
|
|
@ -1,6 +1,5 @@
|
|||
open Syntax
|
||||
open Babillard
|
||||
open Db
|
||||
|
||||
let pp_post fmt t =
|
||||
let thread_data_opt, post =
|
||||
|
|
@ -50,7 +49,7 @@ let pp_post fmt t =
|
|||
let replies_view fmt () =
|
||||
if Option.is_some thread_data_opt then
|
||||
(* TODO put thread_posts count in thread_info ? *)
|
||||
let res_nb = Db.find Q.count_thread_posts id in
|
||||
let res_nb = Q.count_thread_posts id in
|
||||
match res_nb with
|
||||
| Error _ -> Format.fprintf fmt ""
|
||||
| Ok ((1 | 2) as nb) ->
|
||||
|
|
@ -164,7 +163,7 @@ let pp_thread_preview fmt op =
|
|||
thread_preview
|
||||
|
||||
let catalog_content () =
|
||||
let^ ids = Db.collect_list Q.get_threads () in
|
||||
let* ids = Q.get_threads () in
|
||||
let* ops = get_ops ids in
|
||||
Ok
|
||||
(Format.asprintf "%a"
|
||||
|
|
@ -244,7 +243,7 @@ let pp_thread fmt op posts =
|
|||
|
||||
let view_thread thread_id =
|
||||
let* op = get_op thread_id in
|
||||
let^ ids = Db.collect_list Q.get_thread_posts thread_id in
|
||||
let* ids = Q.get_thread_posts thread_id in
|
||||
let* posts = get_posts ids in
|
||||
let s =
|
||||
(Format.asprintf "%a" (fun fmt (op, posts) -> pp_thread fmt op posts))
|
||||
|
|
@ -273,7 +272,7 @@ let pp_marker fmt op =
|
|||
Yojson.pretty_print fmt json
|
||||
|
||||
let get_markers () =
|
||||
let^ ids = Db.collect_list Q.get_threads () in
|
||||
let* ids = Q.get_threads () in
|
||||
let* ops = get_ops ids in
|
||||
let markers =
|
||||
Format.asprintf "[%a]"
|
||||
|
|
@ -329,7 +328,7 @@ let pp_feed_entry fmt post =
|
|||
|
||||
let feed thread_id =
|
||||
let* thread_data, op_post = get_op thread_id in
|
||||
let^ ids = Db.collect_list Q.get_thread_posts thread_id in
|
||||
let* ids = Q.get_thread_posts thread_id in
|
||||
let* posts = get_posts ids in
|
||||
let posts = List.sort (fun a b -> compare b.date a.date) posts in
|
||||
let* last_update =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue