|
|
@@ -25,28 +25,29 @@
|
|
|
(gethash "lat" location)))))))))
|
|
|
|
|
|
(defun load-checkins (from)
|
|
|
- (loop for item in
|
|
|
- (gethash
|
|
|
- "items"
|
|
|
- (gethash
|
|
|
- "checkins"
|
|
|
+ (let ((checkins
|
|
|
(gethash
|
|
|
- "response"
|
|
|
- (yason:parse
|
|
|
- (flexi-streams:octets-to-string
|
|
|
- (drakma:http-request
|
|
|
- "https://api.foursquare.com/v2/users/self/checkins"
|
|
|
- :parameters (list
|
|
|
- (cons "oauth_token" *access-token*)
|
|
|
- (cons "limit" "250")
|
|
|
- (cons "sort" "oldestfirst")
|
|
|
- (cons "afterTimestamp" (if from
|
|
|
- (princ-to-string (local-time:timestamp-to-unix from))
|
|
|
- "0"))
|
|
|
- (cons "v" "20140704")))
|
|
|
- :external-format :utf-8)))))
|
|
|
- for doc = (make-checkin-doc item)
|
|
|
- when doc collect doc))
|
|
|
+ "checkins"
|
|
|
+ (gethash
|
|
|
+ "response"
|
|
|
+ (yason:parse
|
|
|
+ (flexi-streams:octets-to-string
|
|
|
+ (drakma:http-request
|
|
|
+ "https://api.foursquare.com/v2/users/self/checkins"
|
|
|
+ :parameters
|
|
|
+ (list
|
|
|
+ (cons "oauth_token" *access-token*)
|
|
|
+ (cons "limit" "250")
|
|
|
+ (cons "sort" "oldestfirst")
|
|
|
+ (cons "afterTimestamp" (if from
|
|
|
+ (princ-to-string (1+ (local-time:timestamp-to-unix from)))
|
|
|
+ "0"))
|
|
|
+ (cons "v" "20140704")))
|
|
|
+ :external-format :utf-8))))))
|
|
|
+ (when checkins
|
|
|
+ (loop for item in (gethash "items" checkins)
|
|
|
+ for doc = (make-checkin-doc item)
|
|
|
+ when doc collect doc))))
|
|
|
|
|
|
(defun on-cron ()
|
|
|
(let* ((last-checkin (first (docs (db.sort "events" ($ "type" "checkin") :field "ts"
|