From bf9991026a70a7ffe87193a4ca2cbb98e443dd84 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 21 Dec 2017 13:54:02 +0100 Subject: refactor(lisp): Use imported symbols with local qualification ... except hunchentoot, I like using that fully-qualified because it's a great word. --- src/gemma.lisp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/gemma.lisp b/src/gemma.lisp index e0e52854bed8..279cbb3cceaa 100644 --- a/src/gemma.lisp +++ b/src/gemma.lisp @@ -9,7 +9,6 @@ (defpackage gemma (:use :cl - :hunchentoot :local-time :cl-json)) (in-package :gemma) @@ -41,7 +40,7 @@ :accessor description-of) ;; Last completion time - (done-at :type local-time:timestamp + (done-at :type timestamp :initarg :done-at :accessor last-done-at))) @@ -66,7 +65,7 @@ (quote ((name ,task-name) (days ,days) (description ,(or description "")) - (done-at ,(local-time:now))))) + (done-at ,(now))))) (cl-prevalence:snapshot *p-tasks*)))) (defun get-task (name) @@ -78,10 +77,9 @@ (defun days-remaining (task) "Returns the number of days remaining before the supplied TASK reaches its maximum interval." - (let* ((expires-at (local-time:timestamp+ (last-done-at task) - (days-of task) :day)) - (secs-until-expiry (local-time:timestamp-difference expires-at - (local-time:now)))) + (let* ((expires-at (timestamp+ (last-done-at task) + (days-of task) :day)) + (secs-until-expiry (timestamp-difference expires-at (now)))) (round (/ secs-until-expiry 60 60 24)))) (defun sort-tasks (tasks) @@ -94,7 +92,7 @@ maximum interval." "Mark the task with NAME as completed, either now or AT specified time." (cl-prevalence:tx-change-object-slots *p-tasks* 'task (id (get-task name)) - `((done-at ,(or at (local-time:now))))) + `((done-at ,(or at (now))))) (cl-prevalence:snapshot *p-tasks*)) ;; @@ -119,7 +117,7 @@ maximum interval." (setf (hunchentoot:content-type*) "application/json") (setf (hunchentoot:header-out "Access-Control-Allow-Origin") "*") - (json:encode-json-to-string + (encode-json-to-string ;; Construct a frontend-friendly representation of the tasks. (mapcar #'response-for (sort-tasks (list-tasks))))) @@ -127,10 +125,10 @@ maximum interval." (hunchentoot:define-easy-handler (complete-task-handler :uri "/complete") (task) (setf (hunchentoot:content-type*) "application/json") - (let* ((key (intern (json:camel-case-to-lisp task) "GEMMA"))) + (let* ((key (intern (camel-case-to-lisp task) "GEMMA"))) (format t "Marking task ~A as completed" key) (complete-task key) - (json:encode-json-to-string (response-for (get-task key)))))) + (encode-json-to-string (response-for (get-task key)))))) ;; (not-so) example tasks @@ -159,9 +157,9 @@ maximum interval." (mapcar (lambda (task) (complete-task (name-of task) - (local-time:timestamp- (local-time:now) - (random 14) - :day))) + (timestamp- (now) + (random 14) + :day))) (cl-prevalence:find-all-objects *p-tasks* 'task))) (defun clear-all-tasks () -- cgit 1.4.1