summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/category.lisp19
-rw-r--r--database/run.lisp17
-rw-r--r--database/seeds.lisp8
3 files changed, 44 insertions, 0 deletions
diff --git a/database/category.lisp b/database/category.lisp
new file mode 100644
index 0000000..4416331
--- /dev/null
+++ b/database/category.lisp
@@ -0,0 +1,19 @@
+(mito:deftable category ()
+ ((name :col-type (:varchar 128))
+ (percentage :col-type (:varchar 128)))
+ (:record-timestamps nil)
+ (:conc-name category-))
+
+(mito:deftable category-split ()
+ ((name :col-type (:varchar 128))
+ (category :col-type category))
+ (:record-timestamps nil)
+ (:conc-name category-split-))
+
+(defun category-splits (category)
+ (mito:select-dao 'category-split
+ (sxql:where (:= :category category))
+ ;; Assumption that split categories are entered in the correct order by id
+ (sxql:order-by :id)))
+
+;; 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;
diff --git a/database/run.lisp b/database/run.lisp
new file mode 100644
index 0000000..30b8342
--- /dev/null
+++ b/database/run.lisp
@@ -0,0 +1,17 @@
+(mito:deftable run ()
+ ((category :col-type category))
+ (:record-timestamps nil)
+ (:conc-name run-))
+
+(mito:deftable run-split ()
+ ((run :col-type run)
+ (category-split :col-type category-split)
+ (start-time :col-type (or :datetime :null))
+ (end-time :col-type (or :datetime :null)))
+ (:record-timestamps nil)
+ (:conc-name run-split-))
+
+(defun run-splits (run)
+ (mito:select-dao 'run-split
+ (sxql:order-by :category_split_id)
+ (sxql:where (:= :run run))))
diff --git a/database/seeds.lisp b/database/seeds.lisp
new file mode 100644
index 0000000..769676d
--- /dev/null
+++ b/database/seeds.lisp
@@ -0,0 +1,8 @@
+(mito:create-dao 'category :name "Super Metroid" :percentage "Any%"))
+
+(mito:create-dao 'category :name "Portal 1" :percentage "Any%"))
+
+(mito:create-dao 'category :name "Super Mario 64" :percentage "16 Stars"))
+
+(mito:create-dao 'category :name "Minecraft" :percentage "Any% RSG"))
+(mito:create-dao 'category :name "Minecraft" :percentage "Any% SSG"))