From c188ed2bafaa0acb62df3cc5dbf8fb7eff9dc019 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 17 May 2024 11:45:26 +0200 Subject: [PATCH] write track data to database, JSON-encoded --- scopes.asd | 2 +- storage/tracking.lisp | 5 +++-- test/test-storage.lisp | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scopes.asd b/scopes.asd index 3ac80bf..a9e9ca3 100644 --- a/scopes.asd +++ b/scopes.asd @@ -6,7 +6,7 @@ :version "0.0.1" :homepage "https://www.cyberconcepts.org" :description "" - :depends-on (:dbi :local-time :str :sxql) + :depends-on (:com.inuoe.jzon :dbi :local-time :str :sxql) :components ((:file "forge/forge") (:file "storage/storage") (:file "storage/tracking" :depends-on ("storage/storage")) diff --git a/storage/tracking.lisp b/storage/tracking.lisp index f9d5a6e..9a62b4d 100644 --- a/storage/tracking.lisp +++ b/storage/tracking.lisp @@ -4,7 +4,8 @@ (defpackage :scopes/storage/tracking (:use :common-lisp) - (:local-nicknames (:storage :scopes/storage)) + (:local-nicknames (:jzon :com.inuoe.jzon) + (:storage :scopes/storage)) (:export #:track #:trackid #:head #:head-proplist #:time-stamp #:data #:container #:make-item @@ -51,7 +52,7 @@ (if trid (setf (getf vl :trackid) trid)) (if ts (setf (getf vl :timestamp) (storage:timestamp-to-sql (engine track) ts))) - (if data (setf (getf vl :data) data))) + (if data (setf (getf vl :data) (jzon:stringify data)))) vl)) (defun insert (track) diff --git a/test/test-storage.lisp b/test/test-storage.lisp index 0b4643c..bc0a3fc 100644 --- a/test/test-storage.lisp +++ b/test/test-storage.lisp @@ -38,7 +38,7 @@ (t:show-result))) (defun test-track (st) - (let (cont tr) + (let (cont tr (data (make-hash-table :test 'equalp))) (setf cont (make-instance 'tracking:container :storage st)) (storage:drop-table st :tracks) (tracking:create-table cont) @@ -46,6 +46,8 @@ (== (tracking:head tr) '("t01" "john")) (== (tracking:head-proplist tr) '(:username "john" :taskid "t01")) (== (tracking:data tr) nil) + (setf (gethash :desc data) "scopes/storage: queries") + (setf (tracking:data tr) data) (tracking:insert tr) (== (tracking:trackid tr) 1) ))