aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-09-11 10:26:31 +0100
committerChristopher Baines <mail@cbaines.net>2023-09-12 13:11:00 +0100
commitdcf04d89e6f30806b3de5c8171bb95492aaf24e3 (patch)
tree3bb724f1ba053477ed3ce8798fb7263ac3108340
parent406ff79619619742fcf12c2f411407cf82e368c1 (diff)
downloadnar-herder-dcf04d89e6f30806b3de5c8171bb95492aaf24e3.tar
nar-herder-dcf04d89e6f30806b3de5c8171bb95492aaf24e3.tar.gz
Enforce an ordering in database-select-recent-changes
-rw-r--r--nar-herder/database.scm29
1 files changed, 15 insertions, 14 deletions
diff --git a/nar-herder/database.scm b/nar-herder/database.scm
index 521e7cc..186ef6c 100644
--- a/nar-herder/database.scm
+++ b/nar-herder/database.scm
@@ -898,26 +898,27 @@ SELECT id, contents FROM narinfos WHERE substr(store_path, 12, 32) = :hash"
(sqlite-prepare
db
"
-SELECT datetime, change, data FROM recent_changes WHERE datetime >= :datetime LIMIT :limit"
+SELECT datetime, change, data
+FROM recent_changes
+WHERE datetime >= :datetime
+ORDER BY datetime ASC
+LIMIT :limit"
#:cache? #t)))
(sqlite-bind-arguments
statement
#:datetime after-date
#:limit limit)
- (let loop ((row (sqlite-step statement))
- (result '()))
- (match row
- (#(datetime change data)
- (loop (sqlite-step statement)
- (cons `((datetime . ,datetime)
- (change . ,change)
- (data . ,data))
- result)))
- (#f
- (sqlite-reset statement)
-
- (reverse result))))))))
+ (let ((result
+ (sqlite-map
+ (match-lambda
+ (#(datetime change data)
+ `((datetime . ,datetime)
+ (change . ,change)
+ (data . ,data))))
+ statement)))
+ (sqlite-reset statement)
+ result)))))
(define (database-select-latest-recent-change-datetime database)
(call-with-worker-thread