summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-11-25 23:34:33 -0500
committerAndrew Cady <d@jerkface.net>2022-11-25 23:34:33 -0500
commit186c118566bca45bf23996424c910042c2c5dd7b (patch)
tree93e2c3f31b48552545ae4ae0f41e76945fe6c008
parent45f8f923162e4050fc03afbc407017e22525a3e6 (diff)
show accessory lift weights
-rwxr-xr-xrepgoal.hs48
1 files changed, 25 insertions, 23 deletions
diff --git a/repgoal.hs b/repgoal.hs
index c512a94..cb9cee3 100755
--- a/repgoal.hs
+++ b/repgoal.hs
@@ -106,18 +106,16 @@ bestPerformance = head . sortBy (flip $ comparing computeOneRepMax)
106computeOneRepMax :: Performance -> Rational 106computeOneRepMax :: Performance -> Rational
107computeOneRepMax Achieved{..} = toRational achievedWeight * (realToFrac achievedReps * 0.0333 + 1) 107computeOneRepMax Achieved{..} = toRational achievedWeight * (realToFrac achievedReps * 0.0333 + 1)
108 108
109showRational' :: Rational -> String 109showRealFrac' :: (RealFrac n, PrintfArg n ) => n -> String
110showRational' n = printf format $ (realToFrac :: Rational -> Float) $ n 110showRealFrac' n = printf "%.0f" n
111 where
112 format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.1f"
113 111
114showFloatConcise :: Float -> String 112showRealFrac :: (RealFrac n, PrintfArg n ) => n -> String
115showFloatConcise n = printf format n 113showRealFrac 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
119showRational :: Rational -> String 117showRational :: Rational -> String
120showRational = showFloatConcise . realToFrac 118showRational = (showRealFrac :: Float -> String) . fromRational
121 119
122data WeekSelection = Week1 | Week2 | Week3 | Week4 deriving (Enum, Bounded, Show, Eq) 120data 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
180liftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]] 178liftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]]
181liftRows week (Lift _name Wendler, Just liftRecord) = 179liftRows week (Lift _name Wendler, Just liftRecord) =
182 (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow liftRecord 180 (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow liftRecord
183liftRows _ (Lift name (Accessory sets reps), _) = 181liftRows _ (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
185liftRows _ (Lift name Unspecified, _) = 183liftRows _ (Lift name Unspecified, _) = [unspecifiedLiftRow name]
186 [unspecifiedLiftRow name] 184
187 185accessoryLiftRow :: Maybe LiftRecord -> Text -> Int -> (ListPosition, Int) -> [Widget n]
188accessoryLiftRow :: Text -> Int -> (ListPosition, Int) -> [Widget n] 186accessoryLiftRow liftRecords name targetReps (position, _) =
189accessoryLiftRow 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
198unspecifiedLiftRow :: Text -> [Widget n] 200unspecifiedLiftRow :: Text -> [Widget n]
199unspecifiedLiftRow name = map (padLeftRight 2) [ 201unspecifiedLiftRow 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