From c0c6b10e94ba4c2513d85b7ab013b1691d5bc252 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 26 Jul 2024 16:17:54 +0200 Subject: [PATCH] storage/tracking: create special function item-head-fields (for container), use only for table creation --- shape/shape.lisp | 2 +- storage/tracking.lisp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/shape/shape.lisp b/shape/shape.lisp index 4350b69..44e130d 100644 --- a/shape/shape.lisp +++ b/shape/shape.lisp @@ -10,7 +10,7 @@ (defclass record () ((head-fields :reader head-fields :initarg :head-fields :initform '(:taskid :username) :allocation :class) - (head :reader head :initarg :head) + (head :accessor head :initarg :head) (data :accessor data :initarg :data :initform nil))) (defun head-plist (track) diff --git a/storage/tracking.lisp b/storage/tracking.lisp index 55ec5f1..39a61a8 100644 --- a/storage/tracking.lisp +++ b/storage/tracking.lisp @@ -29,7 +29,7 @@ (indexes :reader indexes :initform '((taskid username) (username))) (storage :reader storage :initarg :storage))) -(defmethod shape:head-fields ((cont container)) +(defun item-head-fields (cont) (shape:head-fields (make-instance (item-class cont)))) (defun make-item (cont &rest head) @@ -60,18 +60,19 @@ track)) (defun get-track (cont trid) - (let* ((st (storage cont)) + (let* ((tr (make-item cont)) + (st (storage cont)) (table (storage:qualified-table-name st (table-name cont))) - (cols (append (shape:head-fields cont) '(:timestamp :data))) + (cols (append (shape:head-fields tr) '(:timestamp :data))) (row (storage:normalize-plist (car (storage:query st (sxql:select cols (sxql:from table) (sxql:where (:= :trackid trid)))))))) - (build-track cont row))) + (setup-track tr row))) -(defun build-track (cont row) - (let* ((hv (mapcar #'(lambda (x) (getf row x)) (shape:head-fields cont))) - (tr (apply #'make-item cont hv))) +(defun setup-track (tr row) + (let ((hv (mapcar #'(lambda (x) (getf row x)) (shape:head-fields tr)))) + (setf (shape:head tr) hv) (setf (trackid tr) (getf row :trackid)) (setf (time-stamp tr) (getf row :timestamp)) (setf (shape:data tr) @@ -83,7 +84,7 @@ ((st (storage cont)) (tn (table-name cont)) (table (storage:qualified-table-name st tn)) - (head-fields (shape:head-fields cont)) + (head-fields (item-head-fields cont)) (params (storage:params st)) (id-type (getf params :id-type)) (json-type (getf params :json-type))