From eff95690dbb1200bd66c730bc1aef6b686d13ec3 Mon Sep 17 00:00:00 2001 From: shoshin Date: Fri, 14 Apr 2023 22:07:37 -0500 Subject: Clean: some docstrings, new print-object method --- model.lisp | 27 ++++++++++++++++----------- steam.lisp | 10 +++------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/model.lisp b/model.lisp index 3f0e4a1..7c863aa 100644 --- a/model.lisp +++ b/model.lisp @@ -7,26 +7,31 @@ (games :accessor games))) (defclass game (db:store-object) - ((name :initarg :name :reader name - :index-type idx:string-unique-index - :index-reader game-with-name - :index-values all-games) + ((name + :initarg :name + :reader name + :index-type idx:string-unique-index + :index-reader game-with-name + :index-values all-games) (rating :accessor rating) (playtime :accessor playtime) (icon-url :accessor icon-url) (last-played :accessor last-played)) (:metaclass db:persistent-class)) +(defmethod print-object ((object game) stream) + (print-unreadable-object (object stream :type t :identity t) + (princ (name object) stream))) + (defclass steam-game (game) - ((appid :initarg :appid :reader appid - :index-type idx:unique-index - :index-initargs (:test #'equal) - :index-reader steam-game-with-appid)) + ((appid + :initarg :appid + :reader appid + :index-type idx:unique-index + :index-initargs (:test #'equal) + :index-reader steam-game-with-appid)) (:metaclass db:persistent-class)) -(defmethod print-object ((object steam-game) stream) - (format stream "#" (name object))) - (defclass feat (db:store-object) ((game :reader game diff --git a/steam.lisp b/steam.lisp index 5bc49a8..f8fa64c 100644 --- a/steam.lisp +++ b/steam.lisp @@ -2,12 +2,6 @@ (defvar steam-host "api.steampowered.com") -(defun set-steam-key (key) - (setf (steam-key *config*) key)) - -(defun set-steam-id (id) - (setf (steam-user-id *config*) id)) - ;; JSON ;; * The API returns an object containing the named object with the result data. ;; * Arrays are represented as an array with the name of the type of the objects @@ -122,13 +116,15 @@ game rec))))) (defun load-steam-games () - "Fetch and wrap STEAM-GAMES as persistent objects. + "Fetch and wrap STEAM-GAMEs as persistent objects. WARNING! Not idempotent!" (db:with-transaction () (loop for data in (fetch-steam-games) do (make-steam-game data)))) (defun load-achievement-data (game) + "Fetch and wrap STEAM-ACHIEVEMENTs as persistent objects. +WARNING! Not idempotent!" (loop for schema in (fetch-steam-game-schema game) for achievements in (fetch-steam-achievements game) do (make-steam-achievement game schema achievements))) -- cgit v1.2.3