let get_list_of_target_ids t query =
all_targets t
>>= fun targets ->
let list_of_ids =
match query with
| `All -> List.map targets ~f:Ketrew_target.id
| `Not_finished_before time ->
Log.(s "Getting targets not-finished-before: " % Time.log time @ verbose);
List.filter_map targets ~f:(fun t ->
let st = Ketrew_target.state t in
match Ketrew_target.State.finished_time st with
| Some t when t < time -> None
| _ -> Some (Ketrew_target.id t))
| `Created_after time ->
Log.(s "Getting targets created after: " % Time.log time @ verbose);
List.filter_map targets ~f:(fun t ->
let pt = Ketrew_target.(state t |> State.passive_time) in
match pt < time with
| true -> None
| false -> Some (Ketrew_target.id t))
in
return list_of_ids