Add super mario 64 16 star speedrun; add personal best and speedrun listing helper functions

This commit is contained in:
Logan Hunt 2022-06-01 23:46:09 -07:00
parent a76bfbf944
commit 95409b0713
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 52B3774857EB24B1
2 changed files with 52 additions and 7 deletions

View File

@ -0,0 +1,18 @@
[category]
:name Super Mario 64
:percentage 16 Stars Any%
[splits]
:name Bobomb Battlefield
:name Whomp's Fortress
:name Cool Cool Mountain
:name Bowser in the Dark World
:name Shifting Sand Land
:name Lethal Lava Land
:name Hazy Maze Cave
:name MIPS Clip
:name Dire, dire docks
:name Bowser in the Fire Sea
:name BLJ's
:name Bowser in the Sky

View File

@ -11,6 +11,8 @@
(:record-timestamps nil)
(:conc-name run-split-))
(defun run-splits (run)
(mito:select-dao 'run-split
(sxql:order-by :category_split_id)
@ -30,12 +32,37 @@
(format-time (make-time-alist elapsed))
"-")))
;;(defun best-split (category-split)
;; (mito:select-dao 'run-split
;; (sxql:order-by (:- V
;; Returns stuff like PB, best of each split, etc.
(defun run-statistics (category)
`((asdf . 1)))
;; select *, sum(julianday(end_time)-julianday(start_time))*24*60*60 as total_time from run_split group by run_id order by total_time;
(defmacro query-with-runs-elapsed (&rest body)
`(mito:retrieve-by-sql
(sxql:select (:* (:as (:raw "sum(julianday(end_time) - julianday(start_time))*24*60*60") :elapsed))
(sxql:from :run_split)
(sxql:group-by :run_id)
,@body)))
(defun best-category-run (category)
(query-with-runs-elapsed
(sxql:inner-join :run :on (:= :run_id :run.id))
(sxql:order-by :elapsed)
(sxql:limit 1)
(sxql:where (:= :category_id (mito:object-id category)))))
(defun best-category-split (category-split)
(query-with-runs-elapsed
(sxql:inner-join :category_split :on (:= :category_split_id :category_split.id))
(sxql:order-by :elapsed)
(sxql:limit 1)
(sxql:where (:= :category_split_id (mito:object-id category-split)))))
(defun list-runs (&key (order-element :end-time) (direction :asc))
(query-with-runs-elapsed
(sxql:inner-join :run :on (:= :run_id :run.id))
(sxql:inner-join :category :on (:= :category_id :category.id))
(sxql:order-by (list direction order-element))))
(defun list-category-runs (category &key (order-element :elapsed) (direction :asc))
(query-with-runs-elapsed
(sxql:inner-join :run :on (:= :run_id :run.id))
(sxql:order-by (list direction order-element))
(sxql:where (:= :category_id (mito:object-id category)))))