-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔪 reps-per-round #83
🔪 reps-per-round #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
|
||
(def params-with-rounds-reps | ||
{:rounds-to-score 3 | ||
:reps-per-round 100 | ||
:date "2023-07-14" | ||
:notes-1 "fell off my pace" | ||
:scale "rx" | ||
|
@@ -58,31 +57,30 @@ | |
|
||
(deftest ->scores | ||
(testing "takes params with reps and outputs formated score" | ||
(is (= [{:reps "116" :index 0 :notes ""} | ||
{:reps "102" :index 1 :notes "fell off my pace"} | ||
{:reps "96" :index 2 :notes "couldnt think anymore"}] | ||
(is (= [{:reps "116" :index 0 :notes "" :id nil} | ||
{:reps "102" :index 1 :notes "fell off my pace" :id nil} | ||
{:reps "96" :index 2 :notes "couldnt think anymore" :id nil}] | ||
(sut/->scores params-with-reps)))) | ||
(testing "defaults rounds to score to 1" | ||
(is (= [{:reps "116" :index 0 :notes ""}] | ||
(is (= [{:reps "116" :index 0 :notes "" :id nil}] | ||
Comment on lines
+60
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think our tests run in ci... these were failing lol |
||
(sut/->scores (dissoc params-with-reps :rounds-to-score))))) | ||
(testing "takes params with rounds and reps" | ||
(is (= [{:rounds "3" :index 0 :reps "116" :notes "" :reps-per-round 100} | ||
(is (= [{:rounds "3" :index 0 :reps "116" :notes "" :id nil} | ||
{:rounds "2" | ||
:index 1 | ||
:reps "102" | ||
:notes "fell off my pace" | ||
:reps-per-round 100} | ||
:id nil} | ||
{:rounds "1" | ||
:index 2 | ||
:reps "96" | ||
:notes "couldnt think anymore" | ||
:reps-per-round 100}] | ||
:notes "couldnt think anymore" :id nil}] | ||
(sut/->scores params-with-rounds-reps)))) | ||
(testing "takes params with minutes seconds" | ||
(is (= [{:minutes "16" :index 0 :seconds "33" :notes ""} | ||
{:minutes "102" :index 1 :seconds "2" :notes "fell off my pace"} | ||
(is (= [{:minutes "16" :index 0 :seconds "33" :notes "" :id nil} | ||
{:minutes "102" :index 1 :seconds "2" :notes "fell off my pace" :id nil} | ||
{:minutes "96" | ||
:index 2 | ||
:seconds "1" | ||
:notes "couldnt think anymore"}] | ||
:notes "couldnt think anymore" :id nil}] | ||
(sut/->scores params-with-minutes-seconds))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
(ns com.spicy.workouts.ui | ||
(:require | ||
[com.biffweb :as biff :refer [q]] | ||
[com.biffweb :as biff] | ||
[com.spicy.results.score :refer [REPS_MULTIPLIER]] | ||
[com.spicy.time :as t] | ||
[com.spicy.ui :as ui])) | ||
|
||
|
||
(defn ->rounds-reps | ||
[reps-per-round reps] | ||
(if (> 0 reps) | ||
"0+0" | ||
(str (quot reps reps-per-round) | ||
"+" | ||
(rem reps reps-per-round)))) | ||
[reps-per-round score] | ||
(if (int? score) | ||
(if (> 0 score) | ||
"0+0" | ||
(str (quot score reps-per-round) | ||
"+" | ||
(rem score reps-per-round))) | ||
(let [rounds (.intValue score) | ||
reps (.intValue (* REPS_MULTIPLIER (- (bigdec score) rounds)))] | ||
(str rounds "+" reps)))) | ||
Comment on lines
+10
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will handle old results that require reps-per-round and new results that we record. We can merge this and things shouldnt break, migrate the old data to be a float, then delete the if block here |
||
|
||
|
||
(comment | ||
|
@@ -37,7 +42,7 @@ | |
|
||
|
||
(defn display-summed-score | ||
[{:keys [workout sets] :as a}] | ||
[{:keys [workout sets] :as _a}] | ||
(when (and (not-empty workout) | ||
(not-empty sets)) | ||
(display-score (merge {:workout workout} {:result-set (merge-set-score-with sets +)})))) | ||
|
@@ -124,9 +129,6 @@ | |
[:select.pink-input.teal-focus#scheme | ||
{:name "scheme" | ||
:required true | ||
:hx-get "/app/workouts/new/scheme-inputs" | ||
:hx-target "#scheme-inputs" | ||
:hx-swap "outerHTML" | ||
:value (when (not (nil? workout)) (name (:workout/scheme workout)))} | ||
[:option {:value "" :label "--Select a Workout Scheme--"}] | ||
[:option {:value "time" | ||
|
@@ -147,13 +149,6 @@ | |
:label "feet"}] | ||
[:option {:value "points" | ||
:label "points"}]]] | ||
(if (= :rounds-reps (:workout/scheme workout)) | ||
[:div#scheme-inputs | ||
[:div.flex.flex-col.w-full | ||
[:label {:for :reps-per-round} "Reps per round"] | ||
[:input.w-full.pink-input.p-2.teal-focus#reps-per-round | ||
{:placeholder "Reps per round" :name "reps-per-round" :required true}]]] | ||
[:div.hidden#scheme-inputs]) | ||
[:div.flex.gap-3.items-center | ||
[:label "Score rounds separately?"] | ||
[:input#score-separately | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of referencing the reps per round to normalize score, we divide by 1000 and add that remainder to the rounds integer.