From 1b4fba3216c62dda3687c36224b567dd2a0c5b3b Mon Sep 17 00:00:00 2001 From: swrup Date: Mon, 23 Feb 2026 11:13:54 +0100 Subject: [PATCH] --- src/http_info.ml | 12 +++--------- src/time.ml | 2 ++ src/time.mli | 2 ++ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/http_info.ml b/src/http_info.ml index 21a6943a..75f24a8f 100644 --- a/src/http_info.ml +++ b/src/http_info.ml @@ -60,16 +60,10 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date = let zero_limits = [] in let* denom_l = Keys.denominations () in - let denom_l = - (* reverse chronological order *) - List.sort - (fun a b -> Stdlib.compare b.Denomination.stamp_start a.stamp_start) - denom_l - in let list_issue_date = - match denom_l with - | [] -> Timestamp.zero - | dn :: _ -> dn.Denomination.stamp_start + List.fold_left + (fun acc dn -> Timestamp.max acc dn.Denomination.stamp_start) + Timestamp.zero denom_l in let denom_l = (* if `?last_issue_date` query param does not exactly match the `stamp_start` diff --git a/src/time.ml b/src/time.ml index 3c5af371..b1789951 100644 --- a/src/time.ml +++ b/src/time.ml @@ -99,6 +99,8 @@ module Timestamp = struct let never = uint64_max let zero = 0L let compare = Int64.unsigned_compare + let min a b = if compare a b < 0 then a else b + let max a b = if compare a b > 0 then a else b (* zero if a >= b; never if b=never; otherwise b - a *) let diff a b = diff --git a/src/time.mli b/src/time.mli index 544e92f9..9430b8a1 100644 --- a/src/time.mli +++ b/src/time.mli @@ -38,6 +38,8 @@ module Timestamp : sig val never : t val zero : t val compare : t -> t -> int + val min : t -> t -> t + val max : t -> t -> t val diff : t -> t -> Relative.t val of_s : int64 -> t