diff options
author | Andrew Cady <d@jerkface.net> | 2022-11-25 23:34:33 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-11-25 23:34:33 -0500 |
commit | 186c118566bca45bf23996424c910042c2c5dd7b (patch) | |
tree | 93e2c3f31b48552545ae4ae0f41e76945fe6c008 | |
parent | 45f8f923162e4050fc03afbc407017e22525a3e6 (diff) |
show accessory lift weights
-rwxr-xr-x | repgoal.hs | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -106,18 +106,16 @@ bestPerformance = head . sortBy (flip $ comparing computeOneRepMax) | |||
106 | computeOneRepMax :: Performance -> Rational | 106 | computeOneRepMax :: Performance -> Rational |
107 | computeOneRepMax Achieved{..} = toRational achievedWeight * (realToFrac achievedReps * 0.0333 + 1) | 107 | computeOneRepMax Achieved{..} = toRational achievedWeight * (realToFrac achievedReps * 0.0333 + 1) |
108 | 108 | ||
109 | showRational' :: Rational -> String | 109 | showRealFrac' :: (RealFrac n, PrintfArg n ) => n -> String |
110 | showRational' n = printf format $ (realToFrac :: Rational -> Float) $ n | 110 | showRealFrac' n = printf "%.0f" n |
111 | where | ||
112 | format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.1f" | ||
113 | 111 | ||
114 | showFloatConcise :: Float -> String | 112 | showRealFrac :: (RealFrac n, PrintfArg n ) => n -> String |
115 | showFloatConcise n = printf format n | 113 | showRealFrac n = printf format n |
116 | where | 114 | where |
117 | format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f" | 115 | format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f" |
118 | 116 | ||
119 | showRational :: Rational -> String | 117 | showRational :: Rational -> String |
120 | showRational = showFloatConcise . realToFrac | 118 | showRational = (showRealFrac :: Float -> String) . fromRational |
121 | 119 | ||
122 | data WeekSelection = Week1 | Week2 | Week3 | Week4 deriving (Enum, Bounded, Show, Eq) | 120 | data WeekSelection = Week1 | Week2 | Week3 | Week4 deriving (Enum, Bounded, Show, Eq) |
123 | 121 | ||
@@ -180,21 +178,25 @@ lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq | |||
180 | liftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]] | 178 | liftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]] |
181 | liftRows week (Lift _name Wendler, Just liftRecord) = | 179 | liftRows week (Lift _name Wendler, Just liftRecord) = |
182 | (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow liftRecord | 180 | (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow liftRecord |
183 | liftRows _ (Lift name (Accessory sets reps), _) = | 181 | liftRows _ (Lift name (Accessory sets reps), liftRecords) = |
184 | (flip map) (annotatePosition $ take sets $ repeat reps) $ accessoryLiftRow name reps | 182 | (flip map) (annotatePosition $ take sets $ repeat reps) $ accessoryLiftRow liftRecords name reps |
185 | liftRows _ (Lift name Unspecified, _) = | 183 | liftRows _ (Lift name Unspecified, _) = [unspecifiedLiftRow name] |
186 | [unspecifiedLiftRow name] | 184 | |
187 | 185 | accessoryLiftRow :: Maybe LiftRecord -> Text -> Int -> (ListPosition, Int) -> [Widget n] | |
188 | accessoryLiftRow :: Text -> Int -> (ListPosition, Int) -> [Widget n] | 186 | accessoryLiftRow liftRecords name targetReps (position, _) = |
189 | accessoryLiftRow name targetReps (position, _) = map (padLeftRight 2) [ | 187 | map (padLeftRight 2) |
190 | txt $ case position of FirstInList -> name; NotFirstInList -> " ", | 188 | [ txt $ case position of FirstInList -> name; NotFirstInList -> " " |
191 | str $ printf "%2d @ %5s" targetReps (" " :: String), | 189 | , str $ printf "%2d @ %3s" targetReps $ fromMaybe (" " :: String) (show <$> targetWeight) |
192 | txt " ", | 190 | , txt " " |
193 | txt " ", | 191 | , txt " " |
194 | txt " ", | 192 | , txt " " |
195 | txt " ", | 193 | , txt " " |
196 | txt " " | 194 | , txt " " |
197 | ] | 195 | ] |
196 | where | ||
197 | targetWeight :: Maybe Integer | ||
198 | targetWeight = join $ fmap achievedWeight . find ((== targetReps) . fromIntegral . achievedReps) . stats <$> liftRecords | ||
199 | |||
198 | unspecifiedLiftRow :: Text -> [Widget n] | 200 | unspecifiedLiftRow :: Text -> [Widget n] |
199 | unspecifiedLiftRow name = map (padLeftRight 2) [ | 201 | unspecifiedLiftRow name = map (padLeftRight 2) [ |
200 | txt name, | 202 | txt name, |
@@ -222,7 +224,7 @@ wendlerLiftRow LiftRecord{..} (position, (SetScheme targetRatio targetReps amrap | |||
222 | pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ", | 224 | pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ", |
223 | pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight, | 225 | pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight, |
224 | pad $ str $ showPlates targetWeight, | 226 | pad $ str $ showPlates targetWeight, |
225 | pad $ str $ showFloatConcise actualIntensity ++ "%", | 227 | pad $ str $ showRealFrac' actualIntensity ++ "%", |
226 | str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ", | 228 | str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ", |
227 | pad $ txt " ", | 229 | pad $ txt " ", |
228 | pad $ txt " " | 230 | pad $ txt " " |
@@ -262,7 +264,7 @@ showPlates (fromIntegral -> wt) = fromMaybe " " $ fmap (ourShow . reverse) $ sho | |||
262 | where | 264 | where |
263 | ourPlates = [45,45,25,25,10,10,10,5,5,2.5] | 265 | ourPlates = [45,45,25,25,10,10,10,5,5,2.5] |
264 | ourShow :: [Rational] -> String | 266 | ourShow :: [Rational] -> String |
265 | ourShow = concat . intersperse " " . map showRational' | 267 | ourShow = concat . intersperse " " . map showRational |
266 | showPlates' 0 _ [] = Nothing | 268 | showPlates' 0 _ [] = Nothing |
267 | showPlates' 0 _ used = Just used | 269 | showPlates' 0 _ used = Just used |
268 | showPlates' need (have:avail) used | have * 2 > need = showPlates' need avail used | 270 | showPlates' need (have:avail) used | have * 2 > need = showPlates' need avail used |