Enhance volume and intensity factor calculations.

Commit
a964ce72aee233fdd3d378658515ca9985a39afd
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
src/MyFitnessTracker-Core/MFTSetGroupLog.class.st
index 0f508a2f..f207a51c 100644..100644
@@ -62,9 +62,15 @@
62 62 { #category : 'as yet unclassified' }
63 63 MFTSetGroupLog >> intensityFactor [
64 64
65 Removed: ^ sets
66 Removed: ifEmpty: [ 0 ]
67 Removed: ifNotEmpty: [ (sets collect: #intensityFactor) max ]
65 Added: | weightedIntensity totalVolume |
66 Added: sets ifEmpty: [ ^ 0 ].
67 Added:
68 Added: totalVolume := self volume.
69 Added: totalVolume = 0 ifTrue: [ ^ 0 ].
70 Added:
71 Added: weightedIntensity := sets sum: [ :each |
72 Added: each intensityFactor * each volume ].
73 Added: ^ (weightedIntensity / totalVolume) asFloat round: 1
68 74 ]
69 75
70 76 { #category : 'initialization' }
@@ -138,5 +144,5 @@
138 144 { #category : 'initialization' }
139 145 MFTSetGroupLog >> volume [
140 146
141 Removed: ^ (sets collect: #volume) sum
147 Added: ^ sets sum: #volume
142 148 ]
src/MyFitnessTracker-Core/MFTSetGroupPrescription.class.st
index 2e6459c6..a4c418ef 100644..100644
@@ -21,6 +21,15 @@
21 21 yourself
22 22 ]
23 23
24 Added: { #category : 'accessing' }
25 Added: MFTSetGroupPrescription >> alternativeExercisesFor: aMFTExercise [
26 Added:
27 Added: ^ sets
28 Added: detect: [ :each | each exercise = aMFTExercise ]
29 Added: ifFound: [ :set | set alternativeExercises ]
30 Added: ifNone: [ nil ]
31 Added: ]
32 Added:
24 33 { #category : 'initialization' }
25 34 MFTSetGroupPrescription >> initialize [
26 35
src/MyFitnessTracker-Core/MFTSetLog.class.st
index 4501665d..e3614c03 100644..100644
@@ -72,7 +72,7 @@
72 72
73 73 failureAchieved ifTrue: [ ^ 100 ].
74 74 "TODO: determine intensity factor as a function of PR and maybe workout duration"
75 Removed: ^ 50
75 Added: ^ 0
76 76 ]
77 77
78 78 { #category : 'initialization' }
src/MyFitnessTracker-Core/MFTWorkoutLog.class.st
index 840ed1cb..4f49d9a0 100644..100644
@@ -98,9 +98,15 @@
98 98 { #category : 'as yet unclassified' }
99 99 MFTWorkoutLog >> intensityFactor [
100 100
101 Removed: ^ setGroups
102 Removed: ifEmpty: [ 0 ]
103 Removed: ifNotEmpty: [ (setGroups collect: #intensityFactor) max ]
101 Added: | weightedIntensity totalVolume |
102 Added: setGroups ifEmpty: [ ^ 0 ].
103 Added:
104 Added: totalVolume := self volume.
105 Added: totalVolume = 0 ifTrue: [ ^ 0 ].
106 Added:
107 Added: weightedIntensity := setGroups sum: [ :each |
108 Added: each intensityFactor * each volume ].
109 Added: ^ (weightedIntensity / totalVolume) asFloat round: 1
104 110 ]
105 111
106 112 { #category : 'testing' }
@@ -195,5 +201,5 @@
195 201 { #category : 'accessing' }
196 202 MFTWorkoutLog >> volume [
197 203
198 Removed: ^ (setGroups collect: #volume) sum
204 Added: ^ setGroups sum: #volume
199 205 ]