Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions src/clj/byf/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)))
9 changes: 0 additions & 9 deletions src/clj/byf/datascript.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/clj/byf/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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 :*)
Expand All @@ -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)
Expand Down
13 changes: 1 addition & 12 deletions src/clj/byf/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

(:gen-class))

(defonce system (atom {}))

(defmethod ig/init-key :server/figwheel
[_ {:keys [build] :as opts}]
(log/info "Starting Figwheel")
Expand All @@ -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"))
10 changes: 1 addition & 9 deletions src/clj/byf/fixtures.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
15 changes: 1 addition & 14 deletions src/clj/byf/seed.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
5 changes: 0 additions & 5 deletions src/cljc/byf/games.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 1 addition & 5 deletions src/cljc/byf/generators.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
6 changes: 0 additions & 6 deletions src/cljc/byf/shared_config.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions src/cljs/byf/auth.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
23 changes: 1 addition & 22 deletions src/cljs/byf/common/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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}))

Expand Down Expand Up @@ -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)))
3 changes: 0 additions & 3 deletions src/cljs/byf/common/players.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions src/cljs/byf/elements.cljs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 0 additions & 29 deletions src/cljs/byf/league_detail/desktop.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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])]
Expand Down Expand Up @@ -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))
Expand Down
15 changes: 0 additions & 15 deletions src/cljs/byf/league_detail/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _]
Expand Down Expand Up @@ -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 _]
Expand Down
7 changes: 1 addition & 6 deletions src/cljs/byf/league_detail/mobile.cljs
Original file line number Diff line number Diff line change
@@ -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]))
20 changes: 0 additions & 20 deletions src/cljs/byf/league_detail/rankings.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Loading