This commit is contained in:
parent
90ec2423df
commit
2958d4c600
1 changed files with 21 additions and 15 deletions
36
src/pg.ml
36
src/pg.ml
|
|
@ -208,6 +208,19 @@ module Caqti_type = struct
|
||||||
Caqti_type.(
|
Caqti_type.(
|
||||||
t9 time time amount amount amount time_span int32 time_span master_sig)
|
t9 time time amount amount amount time_span int32 time_span master_sig)
|
||||||
|
|
||||||
|
let aggregate_transfer_fee =
|
||||||
|
let master_sig = Bin_sig.MasterWireFee.caqti in
|
||||||
|
Caqti_type.custom
|
||||||
|
~encode:(fun
|
||||||
|
AggregateTransferFee.
|
||||||
|
{ wire_fee; closing_fee; start_date; end_date; sig_ }
|
||||||
|
-> Ok (wire_fee, closing_fee, start_date, end_date, sig_))
|
||||||
|
~decode:(fun (wire_fee, closing_fee, start_date, end_date, sig_) ->
|
||||||
|
Ok
|
||||||
|
AggregateTransferFee.
|
||||||
|
{ wire_fee; closing_fee; start_date; end_date; sig_ })
|
||||||
|
Caqti_type.(t5 amount amount time time master_sig)
|
||||||
|
|
||||||
include Caqti_request.Infix
|
include Caqti_request.Infix
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -349,31 +362,24 @@ let insert_wire_fee =
|
||||||
Conn.exec insert_wire_fee
|
Conn.exec insert_wire_fee
|
||||||
(wire_method, fee_start, fee_end, wire_fee, closing_fee, master_sig_wire)
|
(wire_method, fee_start, fee_end, wire_fee, closing_fee, master_sig_wire)
|
||||||
|
|
||||||
(* TODO return type, use AggregateTransferFee.t *)
|
|
||||||
let get_wire_fees_by_time =
|
let get_wire_fees_by_time =
|
||||||
let lookup_wire_fee_by_time =
|
let lookup_wire_fee_by_time =
|
||||||
Caqti_type.(t3 wire_method time time ->* t2 amount amount)
|
Caqti_type.(t3 wire_method time time ->* aggregate_transfer_fee)
|
||||||
"SELECT (wire_fee).*, (closing_fee).* FROM wire_fee WHERE wire_method=$1 \
|
"SELECT (wire_fee).*, (closing_fee).*, start_date, end_date, master_sig \
|
||||||
AND end_date > $2 AND start_date < $3"
|
FROM wire_fee WHERE wire_method=$1 AND end_date > $2 AND start_date < \
|
||||||
|
$3"
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) ~wire_method ~start_date ~end_date ->
|
fun (module Conn : CONN) ~wire_method ~start_date ~end_date ->
|
||||||
Conn.collect_list lookup_wire_fee_by_time (wire_method, start_date, end_date)
|
Conn.collect_list lookup_wire_fee_by_time (wire_method, start_date, end_date)
|
||||||
|
|
||||||
let get_wire_fees =
|
let get_wire_fees =
|
||||||
let get_wire_fees =
|
let get_wire_fees =
|
||||||
let master_sig = Bin_sig.MasterWireFee.caqti in
|
Caqti_type.(string ->* aggregate_transfer_fee)
|
||||||
Caqti_type.(string ->* t5 amount amount time time master_sig)
|
"SELECT (wire_fee).*, (closing_fee).*, start_date, end_date, master_sig \
|
||||||
"SELECT wire_fee, closing_fee, start_date, end_date, master_sig FROM \
|
FROM wire_fee WHERE wire_method=$1"
|
||||||
wire_fee WHERE wire_method=$1"
|
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) ~wire_method ->
|
fun (module Conn : CONN) ~wire_method ->
|
||||||
let open Syntax in
|
Conn.collect_list get_wire_fees wire_method
|
||||||
let+ l = Conn.collect_list get_wire_fees wire_method in
|
|
||||||
List.map
|
|
||||||
(fun (wire_fee, closing_fee, start_date, end_date, sig_) ->
|
|
||||||
AggregateTransferFee.
|
|
||||||
{ wire_fee; closing_fee; start_date; end_date; sig_ })
|
|
||||||
l
|
|
||||||
|
|
||||||
let get_global_fees =
|
let get_global_fees =
|
||||||
let get_global_fees =
|
let get_global_fees =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue