Kaynağa Gözat

Minor 4sq fix

Innocenty Enikeew 11 yıl önce
ebeveyn
işleme
4006034230
1 değiştirilmiş dosya ile 22 ekleme ve 21 silme
  1. 22 21
      src/foursquare.lisp

+ 22 - 21
src/foursquare.lisp

@@ -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"