|
|
@@ -92,7 +92,7 @@
|
|
|
(let ((now (local-time:now)))
|
|
|
(loop
|
|
|
for ts = (local-time:parse-timestring from-date) then (local-time:timestamp+ ts 1 :day)
|
|
|
- for locs = (docs->locs (docs (db.sort "locations" (ts->kv "timestampMs" ts) :field "timestampMs" :limit 1440)))
|
|
|
+ for locs = (docs->locs (docs (db.sort "locations" (ts->kv "timestampMs" ts) :field "timestampMs" :limit 1500)))
|
|
|
for places = (extract-places locs)
|
|
|
when places do
|
|
|
(format t "Inserting ~A places for ~A~%" (length places) ts)
|
|
|
@@ -148,15 +148,27 @@
|
|
|
(loop for loc in locations
|
|
|
do (db.insert "locations" (make-location-doc loc))))
|
|
|
|
|
|
+(defun load-locations (from &optional (to (local-time:now)))
|
|
|
+ (docs->locs (docs (db.sort "locations"
|
|
|
+ ($between "timestampMs"
|
|
|
+ (ts->ms from)
|
|
|
+ (ts->ms to))
|
|
|
+ :field "timestampMs"
|
|
|
+ :limit (floor
|
|
|
+ (* 11/600 ; 1 loc per 60 sec + 10%
|
|
|
+ (local-time:timestamp-difference
|
|
|
+ to from)))))))
|
|
|
+
|
|
|
(defun import-location-events (from &optional (to (local-time:timestamp+ from 1 :day)))
|
|
|
(let* ((*google-cookie-jar* (load-chrome-cookie-jar ".google.com"))
|
|
|
(*google-manual-header* (get-history-xsrf-token))
|
|
|
- (locs (load-history from to nil))
|
|
|
- (places (extract-places locs)))
|
|
|
+ (locs (load-history from to nil)))
|
|
|
(format t "Saving ~A locations for ~A~%" (length locs) from)
|
|
|
(save-locations locs)
|
|
|
- (format t "Saving ~A place events for ~A~%" (length places) from)
|
|
|
- (save-places places)))
|
|
|
+ (let* ((with-prev-locs (load-locations (local-time:timestamp- from 400 :sec) to))
|
|
|
+ (places (extract-places with-prev-locs)))
|
|
|
+ (format t "Saving ~A place events~%" (length places))
|
|
|
+ (save-places places))))
|
|
|
|
|
|
(defun find-location-at (ms)
|
|
|
(let* ((ts (ms->ts ms))
|