diff --git a/src/clj/byf/api.clj b/src/clj/byf/api.clj index fecee10..f7ecfff 100644 --- a/src/clj/byf/api.clj +++ b/src/clj/byf/api.clj @@ -28,8 +28,6 @@ (:import (java.util UUID))) (reset! sente/debug-mode?_ true) -(def max-age (* 60 60 24 10)) - (def github-token-path [:oauth2/access-tokens :github :token]) (defn transaction-middleware @@ -39,15 +37,6 @@ (jdbc/with-db-transaction [tx (db/db-spec)] (handler request))))) -(defn uuid-to-str - [m] - (medley/map-vals str m)) - -(defn- as-edn - [response] - (-> response - (resp/content-type "application/edn"))) - (defn my-json-writer [k v] (cond @@ -241,13 +230,6 @@ [params] (assoc-in params [:session :cookie-attrs :same-site] :lax)) -(defn add-cache-control - [handler] - (fn [request] - (ring.util.response/header - (handler request) - "Cache-Control" (format "max-age=%s" max-age)))) - (def app (-> routes-handler (resources/wrap-resource "public") @@ -265,9 +247,4 @@ check-token log-request transaction-middleware - (wrap-oauth2 oauth2-config))) - -(defn -main [& args] - (jetty/run-jetty app {:port (-> :port - value - Integer/parseInt)})) + (wrap-oauth2 oauth2-config))) \ No newline at end of file diff --git a/src/clj/byf/datascript.clj b/src/clj/byf/datascript.clj index 2c4dc9e..1ed99e0 100644 --- a/src/clj/byf/datascript.clj +++ b/src/clj/byf/datascript.clj @@ -4,8 +4,6 @@ [clj-time.core :as t]) (:import (java.util UUID))) -(defn gen-uuid [] (UUID/randomUUID)) - (def schema {:player/name {:db/index true} :game/t1 {:db/index true} :game/t2 {:db/index true} @@ -17,13 +15,6 @@ (def conn (d/create-conn schema)) -(declare render persist) - -(defn reset-conn [db] - (reset! conn db) - (render db) - (persist db)) - ;; find all the games from a given player (def datoms diff --git a/src/clj/byf/db.clj b/src/clj/byf/db.clj index 29601b0..59111a2 100644 --- a/src/clj/byf/db.clj +++ b/src/clj/byf/db.clj @@ -60,11 +60,6 @@ (-> (h/select :*) (h/from :company))) -(defn load-users-sql - [] - (-> (h/select :*) - (h/from [:users]))) - (defn load-league-sql [league-id] (-> (h/select :*) @@ -90,8 +85,6 @@ (defn load-companies [] (query load-companies-sql)) -(defn load-users [] (query load-users-sql)) - (defn- store-sql [params] (-> (h/insert-into :game) diff --git a/src/clj/byf/dev.clj b/src/clj/byf/dev.clj index 9023748..5b3d010 100644 --- a/src/clj/byf/dev.clj +++ b/src/clj/byf/dev.clj @@ -8,8 +8,6 @@ (:gen-class)) -(defonce system (atom {})) - (defmethod ig/init-key :server/figwheel [_ {:keys [build] :as opts}] (log/info "Starting Figwheel") @@ -28,13 +26,4 @@ (defmethod ig/init-key :server/nrepl [_ {:keys [port]}] - (log/info "Starting Nrepl")) - -(def config - {:server/figwheel {:build "dev"} - :server/jetty {:port 3335} - :server/nrepl {}}) - -(defn -main - [& args] - (reset! system (ig/init config))) + (log/info "Starting Nrepl")) \ No newline at end of file diff --git a/src/clj/byf/fixtures.clj b/src/clj/byf/fixtures.clj index 310e330..0c943dc 100644 --- a/src/clj/byf/fixtures.clj +++ b/src/clj/byf/fixtures.clj @@ -23,12 +23,4 @@ ::p1_using ::p2_using ::p1_points - ::p2_points])) - -(defn game-gen - [] - (s/gen ::game)) - -(defn player-gen - [] - (s/gen ::player)) + ::p2_points])) \ No newline at end of file diff --git a/src/clj/byf/seed.clj b/src/clj/byf/seed.clj index 3271361..0635f42 100644 --- a/src/clj/byf/seed.clj +++ b/src/clj/byf/seed.clj @@ -19,13 +19,6 @@ :p1_points (rand-nth (shared/opts :fifa :points)) :p2_points (rand-nth (shared/opts :fifa :points))}))) -(defn get-player-ids - [league-id] - (map :id - (db/query (fn [] {:select [:id] - :from [:league_players] - :where [:= :league_id league-id]})))) - (defn random-ts [] (tc/to-sql-time @@ -76,10 +69,4 @@ (defn seed [league-id] - (add-games! league-id (add-players! league-id))) - -(defn -main - [& args] - (seed (create-league!))) - -;; run witn `lein run -m byf.seed` + (add-games! league-id (add-players! league-id)));; run witn `lein run -m byf.seed` diff --git a/src/cljc/byf/games.cljc b/src/cljc/byf/games.cljc index 9fb1047..ae93677 100644 --- a/src/cljc/byf/games.cljc +++ b/src/cljc/byf/games.cljc @@ -84,11 +84,6 @@ (for [[k v] rankings] {:id k :ranking v})))))) -(defn result-str - [game] - (str (:p1 game) " vs " (:p2 game) ": " - (:p1_points game) " - " (:p2_points game))) - (defn- plays? [game player-id] (contains? (set ((juxt :p1 :p2) game)) player-id)) diff --git a/src/cljc/byf/generators.cljc b/src/cljc/byf/generators.cljc index b80fa49..b7cf850 100644 --- a/src/cljc/byf/generators.cljc +++ b/src/cljc/byf/generators.cljc @@ -53,13 +53,9 @@ (def player-gen (gen ::player)) -(def league-gen (gen ::league)) - ;; can make it more specialized? (s/def ::oauth2_token string?) (s/def ::user (s/keys :req-un [::id ::oauth2_token - ::email])) - -(def user-gen (gen ::user)) + ::email])) \ No newline at end of file diff --git a/src/cljc/byf/shared_config.cljc b/src/cljc/byf/shared_config.cljc index 2c95a76..f92390f 100644 --- a/src/cljc/byf/shared_config.cljc +++ b/src/cljc/byf/shared_config.cljc @@ -2,8 +2,6 @@ (def timestamp-format "YYYY-MM-DDZHH:mm:SS") -(def games #{"fifa" "street-fighter" "table-tennis"}) - ;;TODO: add a spec for the game configuration (def games-config {:fifa @@ -27,10 +25,6 @@ :logo "table_tennis.png" :draw? false}}) -(defn term - [game k] - (-> games-config game :terminology k)) - (defn opts [game k] (-> games-config game :form k)) diff --git a/src/cljs/byf/auth.cljs b/src/cljs/byf/auth.cljs index 608df19..bf0a2ff 100644 --- a/src/cljs/byf/auth.cljs +++ b/src/cljs/byf/auth.cljs @@ -9,9 +9,6 @@ (def setter (partial common/setter* page)) (def getter (partial common/getter* page)) -(def default-db - {:current-user nil}) - (rf/reg-sub ::current-user (getter [:current-user])) (rf/reg-event-db ::set-current-user (setter [:current-user])) diff --git a/src/cljs/byf/common/handlers.cljs b/src/cljs/byf/common/handlers.cljs index 05985f3..2abe4f8 100644 --- a/src/cljs/byf/common/handlers.cljs +++ b/src/cljs/byf/common/handlers.cljs @@ -9,20 +9,6 @@ [clojure.test.check.generators :as gen] [clojure.spec.alpha :as s])) -(def edn-request-format - {:write #(with-out-str (pprint/pprint %)) - :content-type "application/edn"}) - -(defn- edn-read-fn - [response] - (reader/read-string (ajax-protocols/-body response))) - -(def edn-response-format - (ajax-interceptors/map->ResponseFormat - {:read edn-read-fn - :description "EDN" - :content-type ["application/edn"]})) - (def request-format (aj/json-request-format)) (def response-format (aj/json-response-format {:keywords? true})) @@ -122,11 +108,4 @@ (rf/reg-event-db id [(->check-db-interceptor page db-spec)] - handler))) - -(defn set-random-db - "Handler capable of simply setting a random intial db. - This can be used instead of initialise-db for example." - [db-spec] - (fn [db _] - (gen/generate db-spec))) + handler))) \ No newline at end of file diff --git a/src/cljs/byf/common/players.cljs b/src/cljs/byf/common/players.cljs index a4da30f..8caa1af 100644 --- a/src/cljs/byf/common/players.cljs +++ b/src/cljs/byf/common/players.cljs @@ -5,9 +5,6 @@ [re-frame.core :as rf])) ;;TODO: add more to the db? -(def db - {:players []}) - (s/def ::players (s/coll-of (s/keys :req-un [::name ::user_id ::league_id diff --git a/src/cljs/byf/elements.cljs b/src/cljs/byf/elements.cljs index 302149b..91f78b1 100644 --- a/src/cljs/byf/elements.cljs +++ b/src/cljs/byf/elements.cljs @@ -1,15 +1,6 @@ (ns byf.elements (:require [byf.utils :refer [classes]])) -(defn el - [tag base-class] - (fn [cls args body] - [tag - (merge args - {:class (classes (conj cls base-class))}) - (when (some? body) - body)])) - (defn input [cls args] [:input diff --git a/src/cljs/byf/league_detail/desktop.cljs b/src/cljs/byf/league_detail/desktop.cljs index 753087e..1c6eb46 100644 --- a/src/cljs/byf/league_detail/desktop.cljs +++ b/src/cljs/byf/league_detail/desktop.cljs @@ -14,13 +14,6 @@ [cljsjs.moment] [re-frame.core :as rf])) -(def timestamp-format "YYYY-MM-DDZhh:mm:SS") -(def vega-last-n-games 20) - -(defn now-format - [] - (.format (js/moment) timestamp-format)) - (defn from-to [s f t] (take (- t f) (drop f s))) @@ -49,11 +42,6 @@ [ant/card [vega/vega-inner filtered-history @rankings-domain]])])))) -(defn mobile? - [] - (js/console.log "avail width " js/window.screen.availWidth) - (< js/window.screen.availWidth 500)) - (defn results [] (let [show-results (rf/subscribe [::handlers/show-results])] @@ -81,23 +69,6 @@ [ant/card [games-table]]]])]))) -(defn set-current-user - "Set the current user to something, defaulting to the already set user?" - [] - (let [players (rf/subscribe [::players-handlers/players]) - sorted-players (sort-by :name @players) - current-user @(rf/subscribe [::handlers/current-user])] - - [ant/form {:layout "inline"} - [ant/form-item - [ant/button - {:on-click #(rf/dispatch [::handlers/store-current-user current-user])} - "Remember Me"]] - - [ant/form-item - [common-views/drop-down-players sorted-players - ::handlers/set-current-user current-user]]])) - (defn go-to-internal [place] (set! (.-hash js/location) place)) diff --git a/src/cljs/byf/league_detail/handlers.cljs b/src/cljs/byf/league_detail/handlers.cljs index 855559c..0d6fc19 100644 --- a/src/cljs/byf/league_detail/handlers.cljs +++ b/src/cljs/byf/league_detail/handlers.cljs @@ -82,10 +82,6 @@ (rf/reg-event-db ::k (setter [:game-config :k])) (rf/reg-event-db ::initial-ranking (setter [:game-config :initial-ranking])) -(defn uuid->name - [name-mapping vals] - (medley/map-keys #(get name-mapping %) vals)) - (rf/reg-sub ::add-user-notification (getter [:add-user-notification])) (rf/reg-event-db ::add-user-notification (fn [db _] @@ -278,17 +274,6 @@ (let [inner (fn [field v] (not (contains? dead-players (field v))))] (filter #(and (inner :p1 %) (inner :p2 %)) games)))) -(defn current-user-transform - [db] - (let [current-user (ck/get :user)] - (if (some? current-user) - ;;TODO: need to set the current user as well - ;;and maybe have a cascade effect there - (-> db - (assoc-in [:game :p1] current-user) - (assoc-in [:current-user] current-user)) - db))) - ;;TODO: improve this structure a bit (rf/reg-event-db ::initialize-db (fn [db _] diff --git a/src/cljs/byf/league_detail/mobile.cljs b/src/cljs/byf/league_detail/mobile.cljs index 7e88c33..3da2d2b 100644 --- a/src/cljs/byf/league_detail/mobile.cljs +++ b/src/cljs/byf/league_detail/mobile.cljs @@ -1,7 +1,2 @@ (ns byf.league-detail.mobile - (:require [antizer.reagent :as ant])) - -(defn root - [] - [ant/button {:size "large"} - "Add game"]) + (:require [antizer.reagent :as ant])) \ No newline at end of file diff --git a/src/cljs/byf/league_detail/rankings.cljs b/src/cljs/byf/league_detail/rankings.cljs index 5be5d91..dd1f4bc 100644 --- a/src/cljs/byf/league_detail/rankings.cljs +++ b/src/cljs/byf/league_detail/rankings.cljs @@ -21,26 +21,6 @@ [:div.result__container (map-indexed el-result (take-last form-size results))]) -(def hide-show-all - [:span.hide__show__all - [:i.fas.fa-eye-slash - {:title "Hide All" - :on-click #(rf/dispatch [::handlers/hide-all])}] - - [:i.fas.fa-eye - {:title "Show All" - :on-click #(rf/dispatch [::handlers/show-all])}]]) - -(def kill-revive-all - [:span - [:i.fas.fa-skull - {:title "Kill All" - :on-click #(rf/dispatch [::handlers/kill-all])}] - - [:i.fas.fa-life-ring - {:title "Revive All" - :on-click #(rf/dispatch [::handlers/revive-all])}]]) - (defn game-slider [] (let [games (rf/subscribe [::handlers/games-live-players]) diff --git a/src/cljs/byf/user/handlers.cljs b/src/cljs/byf/user/handlers.cljs index 1a1057f..28d1e17 100644 --- a/src/cljs/byf/user/handlers.cljs +++ b/src/cljs/byf/user/handlers.cljs @@ -2,9 +2,6 @@ (:require [byf.common.handlers :as common] [re-frame.core :as rf])) -(def db - {:opponent nil}) - (def page ::page-id) ;;TODO: pass the spec