[Pharo] Personal fitness tracker web app.
Set weight; set, exercise, and workout volumes.
Changed files
src/MyFitnessTracker/MFTExercise.class.st
@@ -280,3 +280,11 @@
280
280
281
281
sets := anOrderedCollection
282
282
]
283
Added:
284
Added:
{ #category : #'as yet unclassified' }
285
Added:
MFTExercise >> volume [
286
Added:
287
Added:
^ sets
288
Added:
ifNotEmpty: [ (sets collect: [ :set | set volume ]) sum ]
289
Added:
ifEmpty: 0
290
Added:
]
src/MyFitnessTracker/MFTSet.class.st
@@ -1,13 +1,17 @@
1
1
"
2
2
I represent a single set of an exercise.
3
3
4
Removed:
I am defined by the number of reps performed during the exercise, as well as the Rate of Perceived Exertion.
4
Added:
Instance variables
5
Added:
reps: number of repetitions performed by the user.
6
Added:
weight: weight used for the set.
7
Added:
rpe: rate of perceived exertion, from 1 to 10.
5
8
"
6
9
Class {
7
10
#name : #MFTSet,
8
11
#superclass : #Object,
9
12
#instVars : [
10
13
'reps',
14
Added:
'weight',
11
15
'rpe'
12
16
],
13
17
#category : #MyFitnessTracker
@@ -30,11 +34,22 @@
30
34
yourself
31
35
]
32
36
37
Added:
{ #category : #'as yet unclassified' }
38
Added:
MFTSet class >> reps: anInteger weight: anInteger2 rpe: anInteger3 [
39
Added:
40
Added:
^ self new
41
Added:
reps: anInteger;
42
Added:
weight: anInteger2;
43
Added:
rpe: anInteger3;
44
Added:
yourself
45
Added:
]
46
Added:
33
47
{ #category : #initialization }
34
48
MFTSet >> initialize [
35
49
36
50
super initialize.
37
51
reps := MFTUser defaultReps.
52
Added:
weight := 0.
38
53
rpe := MFTUser defaultRpe
39
54
]
40
55
@@ -60,4 +75,22 @@
60
75
MFTSet >> rpe: aValue [
61
76
62
77
rpe := aValue
78
Added:
]
79
Added:
80
Added:
{ #category : #'as yet unclassified' }
81
Added:
MFTSet >> volume [
82
Added:
83
Added:
^ reps asInteger * weight asInteger
84
Added:
]
85
Added:
86
Added:
{ #category : #accessing }
87
Added:
MFTSet >> weight [
88
Added:
89
Added:
^ weight
90
Added:
]
91
Added:
92
Added:
{ #category : #accessing }
93
Added:
MFTSet >> weight: anObject [
94
Added:
95
Added:
weight := anObject
63
96
]
src/MyFitnessTracker/MFTWorkout.class.st
@@ -29,6 +29,50 @@
29
29
yourself
30
30
]
31
31
32
Added:
{ #category : #'as yet unclassified' }
33
Added:
MFTWorkout class >> placeholderCollection [
34
Added:
35
Added:
| workout1 workout2 workout3 |
36
Added:
workout1 := self new
37
Added:
date: (Date fromString: '01/03/2023');
38
Added:
primaryMuscle: MFTMuscleGroup chest;
39
Added:
exercises: (OrderedCollection
40
Added:
with: (MFTExercise cableRow sets: {
41
Added:
(MFTSet reps: 8 weight: 20 rpe: 6).
42
Added:
(MFTSet reps: 6 weight: 20 rpe: 8).
43
Added:
(MFTSet reps: 6 weight: 20 rpe: 10).
44
Added:
(MFTSet reps: 15 rpe: 4) } asOrderedCollection)
45
Added:
with: (MFTExercise shoulderPressDumbell sets: {
46
Added:
(MFTSet reps: 10 weight: 10 rpe: 6).
47
Added:
(MFTSet reps: 6 weight: 15 rpe: 8).
48
Added:
(MFTSet reps: 6 weight: 17.5 rpe: 10) }
49
Added:
asOrderedCollection)
50
Added:
with: (MFTExercise declineBenchPress sets: {
51
Added:
(MFTSet reps: 5 rpe: 6).
52
Added:
(MFTSet reps: 6 rpe: 8).
53
Added:
(MFTSet reps: 8 rpe: 10) } asOrderedCollection)).
54
Added:
workout2 := self new
55
Added:
date: (Date fromString: '01/02/2023');
56
Added:
exercises: (OrderedCollection
57
Added:
with: (MFTExercise cableRow sets: {
58
Added:
(MFTSet reps: 8 rpe: 6).
59
Added:
(MFTSet reps: 6 rpe: 8).
60
Added:
(MFTSet reps: 6 rpe: 10).
61
Added:
(MFTSet reps: 15 rpe: 4) } asOrderedCollection)
62
Added:
with: MFTExercise shoulderPressDumbell
63
Added:
with: MFTExercise declineBenchPress).
64
Added:
workout3 := self new
65
Added:
date: (Date fromString: '01/01/2023');
66
Added:
addExercise: MFTExercise cableRow;
67
Added:
addExercise: MFTExercise shoulderPressDumbell;
68
Added:
addExercise: MFTExercise declineBenchPress.
69
Added:
70
Added:
^ OrderedCollection withAll: {
71
Added:
workout1.
72
Added:
workout2.
73
Added:
workout3 }
74
Added:
]
75
Added:
32
76
{ #category : #accessing }
33
77
MFTWorkout class >> primaryMuscle: aMFTMuscle [
34
78
@@ -136,13 +180,11 @@
136
180
{ #category : #rendering }
137
181
MFTWorkout >> renderContentOn: html [
138
182
139
Removed:
| grandTotal |
140
Removed:
grandTotal := 0.
141
183
html definitionList: [
142
184
date ifNotNil: [
143
185
html
144
186
definitionTerm: 'Date';
145
Removed:
definitionData: date "dayOfWeekName , ', ' , date asString" ].
187
Added:
definitionData: date ].
146
188
primaryMuscle englishName ifNotEmpty: [
147
189
html
148
190
definitionTerm: 'Primary Muscle';
@@ -152,44 +194,58 @@
152
194
definitionTerm: 'Secondary Muscles';
153
195
definitionData:
154
196
(secondaryMuscles collect: #englishName) asCommaString ] ].
155
Removed:
exercises ifNotEmpty: [
156
Removed:
html table
157
Removed:
class: 'table table-striped table-bordered';
158
Removed:
with: [
159
Removed:
self renderTableHeaderOn: html.
160
Removed:
exercises do: [ :exercise |
161
Removed:
html tableRow: [
162
Removed:
html tableData: [
163
Removed:
html
164
Removed:
text: exercise englishName;
165
Removed:
text: ': '.
166
Removed:
exercise sets
167
Removed:
ifNotEmpty: [
168
Removed:
html text: exercise repsBySet asCommaString.
169
Removed:
html tableData: exercise repsBySet sum.
170
Removed:
grandTotal := grandTotal + exercise repsBySet sum ]
171
Removed:
ifEmpty: [
172
Removed:
html text: 0.
173
Removed:
html tableData: 0 ] ] ] ].
174
Removed:
self renderTableFooterTotal: grandTotal on: html ] ]
197
Added:
exercises ifNotEmpty: [ self renderExerciseTableOn: html ]
175
198
]
176
199
177
200
{ #category : #rendering }
178
Removed:
MFTWorkout >> renderTableFooterTotal: grandTotal on: html [
201
Added:
MFTWorkout >> renderExerciseTableFooterOn: html [
179
202
180
Removed:
^ html tableFoot: [
181
Removed:
html
182
Removed:
tableData: 'Total';
183
Removed:
tableData: grandTotal ]
203
Added:
| totalReps totalVolume |
204
Added:
totalReps := (exercises collect: [ :exercise |
205
Added:
exercise repsBySet sum ]) sum.
206
Added:
totalVolume := (exercises collect: #volume) sum.
207
Added:
208
Added:
html tableFoot: [
209
Added:
html
210
Added:
tableData: 'Total';
211
Added:
tableData: totalReps.
212
Added:
totalVolume ~~ 0 ifTrue: [ html tableData: totalVolume ] ]
184
213
]
185
214
186
215
{ #category : #rendering }
216
Added:
MFTWorkout >> renderExerciseTableOn: html [
217
Added:
218
Added:
html table
219
Added:
class: 'table table-striped table-bordered';
220
Added:
with: [
221
Added:
self renderTableHeaderOn: html.
222
Added:
exercises do: [ :exercise |
223
Added:
html tableRow: [
224
Added:
html tableData: [
225
Added:
html
226
Added:
text: exercise englishName;
227
Added:
text: ': '.
228
Added:
exercise sets
229
Added:
ifNotEmpty: [
230
Added:
html text: exercise repsBySet asCommaString.
231
Added:
html tableData: exercise repsBySet sum ]
232
Added:
ifEmpty: [
233
Added:
html text: 0.
234
Added:
html tableData: 0 ] ].
235
Added:
(exercises anySatisfy: [ :ex | ex volume ~~ 0 ]) ifTrue: [
236
Added:
html tableData: exercise volume ] ] ].
237
Added:
self renderExerciseTableFooterOn: html ]
238
Added:
]
239
Added:
240
Added:
{ #category : #rendering }
187
241
MFTWorkout >> renderTableHeaderOn: html [
188
242
189
243
html tableHead: [
190
244
html
191
245
tableHeading: 'Exercise';
192
Removed:
tableHeading: 'Reps' ]
246
Added:
tableHeading: 'Reps'.
247
Added:
(exercises anySatisfy: [ :exercise | exercise volume ~~ 0 ])
248
Added:
ifTrue: [ html tableHeading: 'Volume' ] ]
193
249
]
194
250
195
251
{ #category : #'as yet unclassified' }
@@ -226,4 +282,10 @@
226
282
MFTWorkout >> secondaryMuscles: aMuscleArray [
227
283
228
284
secondaryMuscles := aMuscleArray
285
Added:
]
286
Added:
287
Added:
{ #category : #'as yet unclassified' }
288
Added:
MFTWorkout >> volume [
289
Added:
290
Added:
^ (exercises collect: #volume) sum
229
291
]