Browse Source

Fix cron, update locations cron to allow multy-call

Innocenty Enikeew 11 năm trước cách đây
mục cha
commit
b8a56a0646
2 tập tin đã thay đổi với 11 bổ sung3 xóa
  1. 8 1
      src/locations.lisp
  2. 3 2
      src/web.lisp

+ 8 - 1
src/locations.lisp

@@ -182,4 +182,11 @@
              (get-element "timestampMs" less)))))))
 
 (defun on-cron ()
-  (import-location-events (local-time:timestamp- (today) 1 :day)))
+  (let* ((last-loc (first (docs (db.sort "locations" :all :field "timestampMs"
+                                         :asc nil :limit 1))))
+         (from (or (and last-loc (doc->ts last-loc))
+                   (local-time:timestamp- (today) 3 :day)))
+         (to (local-time:timestamp-minimum
+              (local-time:timestamp+ from 3 :day)
+              (local-time:now))))
+    (import-location-events from to)))

+ 3 - 2
src/web.lisp

@@ -13,8 +13,9 @@
 
 ;; Cron
 (defvar *run-cron* t "Controls if starting a web should run cron tasks")
-(defvar *crons* '((#'timeliner.locations:on-cron (:minute 10 :hour 0))
-                  (#'timeliner.financisto:on-cron (:minute 0 :hour 7)))
+(defvar *crons* (list
+                 (list #'timeliner.locations:on-cron '(:minute 0 :hour *))
+                 (list #'timeliner.financisto:on-cron '(:minute 0 :hour 7)))
   "List of cron functions with their schedules")
 (defvar *cron-timers* nil)