Commit 75c6f2a9 authored by Bheesham Persaud's avatar Bheesham Persaud

Add db; remove Ring et al. until I'm ready to write the server.

parent ed40c43c
......@@ -9,9 +9,8 @@
[environ "1.1.0"]
[mount "0.1.11"]
[io.socket/socket.io-client "1.0.0"]
[compojure "1.6.0"]
[ring/ring-core "1.6.3"]
[ring/ring-jetty-adapter "1.6.3"]]
[org.clojure/java.jdbc "0.7.5"]
[org.xerial/sqlite-jdbc "3.16.1"]]
:main ^:skip-aot com.bheesham.waifu.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
......
CREATE TABLE IF NOT EXISTS fighter_info (
CREATE TABLE IF NOT EXISTS fighter (
id INTEGER PRIMARY KEY,
name TEXT
);
DROP TABLE fighter_elo;
CREATE TABLE IF NOT EXISTS fighter_elo (
id INTEGER PRIMARY KEY,
CREATE TABLE IF NOT EXISTS elo (
fighter INTEGER,
elo INTEGER,
caused_by INTEGER,
FOREIGN KEY (id) REFERENCES fighter_info(id),
PRIMARY KEY(fighter, caused_by),
FOREIGN KEY (fighter) REFERENCES fighter(id),
FOREIGN KEY (caused_by) REFERENCES match(id)
);
DROP TABLE match;
CREATE TABLE IF NOT EXISTS match (
id INTEGER PRIMARY KEY,
one INTEGER,
two INTEGER,
winner INTEGER,
loser INTEGER,
time DATETIME,
FOREIGN KEY (one) REFERENCES fighter_info(id),
FOREIGN KEY (two) REFERENCES fighter_info(id),
FOREIGN KEY (id) REFERENCES fighter_info(id)
);
FOREIGN KEY (winner) REFERENCES fighter(id),
FOREIGN KEY (loser) REFERENCES fighter(id)
);
INSERT INTO fighter (name) VALUES (NULL);
(ns com.bheesham.waifu.db
(:require [clojure.edn :as edn]
[clojure.java.jdbc :as jdbc]
))
(def location "/var/lib/waifu/db.edn")
(def conn (let [spec {:connection-uri "jdbc:sqlite:foo"}]
{:connection-uri (:connection-uri spec)
:connection (jdbc/get-connection spec)}))
(ns com.bheesham.waifu.elo
(:require [clojure.edn :as edn]))
(:require [clojure.edn :as edn]
[com.bheesham.waifu.db :as db]))
(def db-location "/var/lib/waifu/db.edn")
(def algo-of 400.0)
(def k-factor 32)
(def rankings (atom (or (try
(edn/read-string (slurp db-location))
(edn/read-string (slurp db/location))
(catch Exception e
nil))
{})))
......@@ -14,7 +14,7 @@
(add-watch rankings :save
(fn [_ _ _ n]
(try
(spit db-location n)
(spit db/location n)
(catch Exception e
(println "couldn't save the database.")))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment