@@ -17,7 +17,7 @@ use crate::db::model::WebhookDeliveryState;
1717use crate :: db:: model:: WebhookDeliveryTrigger ;
1818use crate :: db:: model:: WebhookEvent ;
1919use crate :: db:: model:: WebhookEventClass ;
20- use crate :: db:: pagination:: paginated ;
20+ use crate :: db:: pagination:: paginated_multicolumn ;
2121use crate :: db:: schema;
2222use crate :: db:: schema:: webhook_delivery:: dsl;
2323use crate :: db:: schema:: webhook_delivery_attempt:: dsl as attempt_dsl;
@@ -140,28 +140,32 @@ impl DataStore {
140140 rx_id : & WebhookReceiverUuid ,
141141 triggers : & ' static [ WebhookDeliveryTrigger ] ,
142142 only_states : Vec < WebhookDeliveryState > ,
143- pagparams : & DataPageParams < ' _ , Uuid > ,
143+ pagparams : & DataPageParams < ' _ , ( DateTime < Utc > , Uuid ) > ,
144144 ) -> ListResultVec < (
145145 WebhookDelivery ,
146146 WebhookEventClass ,
147147 Vec < WebhookDeliveryAttempt > ,
148148 ) > {
149149 let conn = self . pool_connection_authorized ( opctx) . await ?;
150150 // Paginate the query, ordered by delivery UUID.
151- let mut query = paginated ( dsl:: webhook_delivery, dsl:: id, pagparams)
152- // Select only deliveries that are to the receiver we're interested in,
153- // and were initiated by the triggers we're interested in.
154- . filter (
155- dsl:: rx_id
156- . eq ( rx_id. into_untyped_uuid ( ) )
157- . and ( dsl:: trigger. eq_any ( triggers) ) ,
158- )
159- // Join with the event table on the delivery's event ID,
160- // so that we can grab the event class of the event that initiated
161- // this delivery.
162- . inner_join (
163- event_dsl:: webhook_event. on ( dsl:: event_id. eq ( event_dsl:: id) ) ,
164- ) ;
151+ let mut query = paginated_multicolumn (
152+ dsl:: webhook_delivery,
153+ ( dsl:: time_created, dsl:: id) ,
154+ pagparams,
155+ )
156+ // Select only deliveries that are to the receiver we're interested in,
157+ // and were initiated by the triggers we're interested in.
158+ . filter (
159+ dsl:: rx_id
160+ . eq ( rx_id. into_untyped_uuid ( ) )
161+ . and ( dsl:: trigger. eq_any ( triggers) ) ,
162+ )
163+ // Join with the event table on the delivery's event ID,
164+ // so that we can grab the event class of the event that initiated
165+ // this delivery.
166+ . inner_join (
167+ event_dsl:: webhook_event. on ( dsl:: event_id. eq ( event_dsl:: id) ) ,
168+ ) ;
165169 if !only_states. is_empty ( ) {
166170 query = query. filter ( dsl:: state. eq_any ( only_states) ) ;
167171 }
@@ -531,8 +535,9 @@ mod test {
531535 )
532536 . await
533537 . unwrap ( ) ;
534- paginator = p
535- . found_batch ( & deliveries, & |( d, _, _) | * d. id . as_untyped_uuid ( ) ) ;
538+ paginator = p. found_batch ( & deliveries, & |( d, _, _) | {
539+ ( d. time_created , * d. id . as_untyped_uuid ( ) )
540+ } ) ;
536541 all_deliveries
537542 . extend ( deliveries. into_iter ( ) . map ( |( d, _, _) | dbg ! ( d) . id ) ) ;
538543 }
0 commit comments