Skip to content

Instantly share code, notes, and snippets.

@r-moeritz
Created June 16, 2011 18:08
Show Gist options
  • Save r-moeritz/1029843 to your computer and use it in GitHub Desktop.
Save r-moeritz/1029843 to your computer and use it in GitHub Desktop.
game related functions
(defun game-from-name (name)
(clsql:locally-enable-sql-reader-syntax)
(car (clsql:select 'game
:where [= [slot-value 'game 'name] name])))
(defun games ()
(sort (clsql:select 'game) #'> :key #'(lambda (g) (apply #'game-votes g))))
(defun add-game (name)
(unless (game-stored? name)
(let ((g (make-instance 'game :name name)))
(clsql:update-record-from-slots g '(name votes)))))
(defmethod vote-for (user-selected-game)
(let ((g (car user-selected-game)))
(incf (game-votes g))
(clsql:update-record-from-slots g '(votes))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment