scripts: Do full index every 10 cycles.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 16:10:18 +0000 (18:10 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 22 Apr 2020 16:10:18 +0000 (18:10 +0200)
scripts/mumi.in

index 02847e8e92527ad0f92e2185a0f327a6ab798f9b..920b279b405d6c4b5ff2ea36609af21f61f7b61f 100644 (file)
 ;; Keep indexing the mail directory
 (define %update-interval 60)
 
-(define* (update-state! #:key loop?)
-  (catch #t
-    (lambda ()
-      (index!)
-      (let ((nums (sort (append-map (lambda (package)
-                                      (soap-invoke* (%config 'debbugs)
-                                                    get-bugs
-                                                    `((package . ,package))))
-                                    (%config 'packages)) >)))
-        (update-bug-database! nums))
-      (and loop?
-           (begin
-             (format (current-error-port)
-                     "Sleeping for ~a seconds." %update-interval)
-             (sleep %update-interval)
-             (update-state!))))
-    (lambda args
-      (format (current-error-port) "worker error: ~a~%" args)
-      (sleep %update-interval)
-      (update-state!))))
+(define update-state!
+  (let ((count -1))
+    (lambda* (#:key loop?)
+      (set! count (remainder (1+ count) 10))
+      (catch #t
+        (lambda ()
+          (when (zero? count)
+            (display "Starting full indexing." (current-error-port))
+            (newline (current-error-port)))
+          (index! #:full? (zero? count))
+          (let ((nums (sort (append-map (lambda (package)
+                                          (soap-invoke* (%config 'debbugs)
+                                                        get-bugs
+                                                        `((package . ,package))))
+                                        (%config 'packages)) >)))
+            (update-bug-database! nums))
+          (and loop?
+               (begin
+                 (format (current-error-port)
+                         "Sleeping for ~a seconds." %update-interval)
+                 (sleep %update-interval)
+                 (update-state!))))
+        (lambda args
+          (format (current-error-port) "worker error: ~a~%" args)
+          (sleep %update-interval)
+          (update-state!))))))
 
 (define %options
   ;; Specifications of the command-line options