Skip to content

Commit efee16c

Browse files
ISSUE-70: Only include sports which there are activities for in the monthly overview
1 parent c0bdedd commit efee16c

File tree

3 files changed

+92
-90
lines changed

3 files changed

+92
-90
lines changed

templates/html/monthly-stats.html.twig

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,31 @@
8181
</tbody>
8282
<tfoot>
8383
{% for activityType in enum('App\\Domain\\Strava\\Activity\\ActivityType').cases %}
84-
{% set totalsForActivityType = monthlyStatistics.getTotalsForActivityType(activityType) %}
85-
<tr class="font-semibold text-gray-900 {{ loop.first ? 'border-t-4' : '' }}">
86-
<td class="px-2 py-2 text-right sticky left-0 bg-white">
87-
{{ activityType.value }}
88-
</td>
89-
<td class="px-2 py-2">
90-
{{ totalsForActivityType.numberOfWorkouts }}
91-
</td>
92-
<td class="px-2 py-2">
93-
{{ renderComponent('measurement', {'measurement': totalsForActivityType.totalDistance, 'precision': 0}) }}
94-
</td>
95-
<td class="px-2 py-2">
96-
{{ renderComponent('measurement', {'measurement': totalsForActivityType.totalElevation, 'precision': 0}) }}
97-
</td>
98-
<td class="px-2 py-2">
99-
{{ totalsForActivityType.movingTime }}
100-
</td>
101-
<td class="px-2 py-2">
102-
{{ totalsForActivityType.totalCalories|formatNumber(0) }}<span class="text-xs">kcal</span>
103-
</td>
104-
<td class="px-2 py-2">
105-
</td>
106-
</tr>
84+
{% set totalsForActivityType = monthlyStatistics.getTotalsForActivityType(activityType) %}
85+
{% if totalsForActivityType.totalDistance.toFloat() > 0 %}
86+
<tr class="font-semibold text-gray-900 {{ loop.first ? 'border-t-4' : '' }}">
87+
<td class="px-2 py-2 text-right sticky left-0 bg-white">
88+
{{ activityType.value }}
89+
</td>
90+
<td class="px-2 py-2">
91+
{{ totalsForActivityType.numberOfWorkouts }}
92+
</td>
93+
<td class="px-2 py-2">
94+
{{ renderComponent('measurement', {'measurement': totalsForActivityType.totalDistance, 'precision': 0}) }}
95+
</td>
96+
<td class="px-2 py-2">
97+
{{ renderComponent('measurement', {'measurement': totalsForActivityType.totalElevation, 'precision': 0}) }}
98+
</td>
99+
<td class="px-2 py-2">
100+
{{ totalsForActivityType.movingTime }}
101+
</td>
102+
<td class="px-2 py-2">
103+
{{ totalsForActivityType.totalCalories|formatNumber(0) }}<span class="text-xs">kcal</span>
104+
</td>
105+
<td class="px-2 py-2">
106+
</td>
107+
</tr>
108+
{% endif %}
107109
{% endfor %}
108110
<tr class="font-semibold text-gray-900">
109111
<td class="px-2 py-2 text-right sticky left-0 bg-white">

tests/Domain/Strava/BuildHtmlVersion/__snapshots__/BuildHtmlVersionCommandHandlerTest--testHandle--buildhtmlmonthly-stats.html.html

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -193,79 +193,79 @@
193193
</tr>
194194
</tbody>
195195
<tfoot>
196-
<tr class="font-semibold text-gray-900 border-t-4">
197-
<td class="px-2 py-2 text-right sticky left-0 bg-white">
198-
Ride
199-
</td>
200-
<td class="px-2 py-2">
201-
7
202-
</td>
203-
<td class="px-2 py-2">
204-
162<span class="text-xs">km</span>
196+
<tr class="font-semibold text-gray-900 border-t-4">
197+
<td class="px-2 py-2 text-right sticky left-0 bg-white">
198+
Ride
199+
</td>
200+
<td class="px-2 py-2">
201+
7
202+
</td>
203+
<td class="px-2 py-2">
204+
162<span class="text-xs">km</span>
205205

206-
</td>
207-
<td class="px-2 py-2">
208-
81<span class="text-xs">m</span>
206+
</td>
207+
<td class="px-2 py-2">
208+
81<span class="text-xs">m</span>
209209

210-
</td>
211-
<td class="px-2 py-2">
212-
2h 42m
213-
</td>
214-
<td class="px-2 py-2">
215-
1 531<span class="text-xs">kcal</span>
216-
</td>
217-
<td class="px-2 py-2">
218-
</td>
219-
</tr>
220-
<tr class="font-semibold text-gray-900 ">
221-
<td class="px-2 py-2 text-right sticky left-0 bg-white">
222-
VirtualRide
223-
</td>
224-
<td class="px-2 py-2">
225-
4
226-
</td>
227-
<td class="px-2 py-2">
228-
67<span class="text-xs">km</span>
210+
</td>
211+
<td class="px-2 py-2">
212+
2h 42m
213+
</td>
214+
<td class="px-2 py-2">
215+
1 531<span class="text-xs">kcal</span>
216+
</td>
217+
<td class="px-2 py-2">
218+
</td>
219+
</tr>
220+
<tr class="font-semibold text-gray-900 ">
221+
<td class="px-2 py-2 text-right sticky left-0 bg-white">
222+
VirtualRide
223+
</td>
224+
<td class="px-2 py-2">
225+
4
226+
</td>
227+
<td class="px-2 py-2">
228+
67<span class="text-xs">km</span>
229229

230-
</td>
231-
<td class="px-2 py-2">
232-
1 112<span class="text-xs">m</span>
230+
</td>
231+
<td class="px-2 py-2">
232+
1 112<span class="text-xs">m</span>
233233

234-
</td>
235-
<td class="px-2 py-2">
236-
4h 12m
237-
</td>
238-
<td class="px-2 py-2">
239-
2 780<span class="text-xs">kcal</span>
240-
</td>
241-
<td class="px-2 py-2">
242-
</td>
243-
</tr>
244-
<tr class="font-semibold text-gray-900 ">
245-
<td class="px-2 py-2 text-right sticky left-0 bg-white">
246-
Run
247-
</td>
248-
<td class="px-2 py-2">
249-
1
250-
</td>
251-
<td class="px-2 py-2">
252-
50<span class="text-xs">km</span>
234+
</td>
235+
<td class="px-2 py-2">
236+
4h 12m
237+
</td>
238+
<td class="px-2 py-2">
239+
2 780<span class="text-xs">kcal</span>
240+
</td>
241+
<td class="px-2 py-2">
242+
</td>
243+
</tr>
244+
<tr class="font-semibold text-gray-900 ">
245+
<td class="px-2 py-2 text-right sticky left-0 bg-white">
246+
Run
247+
</td>
248+
<td class="px-2 py-2">
249+
1
250+
</td>
251+
<td class="px-2 py-2">
252+
50<span class="text-xs">km</span>
253253

254-
</td>
255-
<td class="px-2 py-2">
256-
278<span class="text-xs">m</span>
254+
</td>
255+
<td class="px-2 py-2">
256+
278<span class="text-xs">m</span>
257257

258-
</td>
259-
<td class="px-2 py-2">
260-
1h 3m
261-
</td>
262-
<td class="px-2 py-2">
263-
695<span class="text-xs">kcal</span>
264-
</td>
265-
<td class="px-2 py-2">
266-
</td>
267-
</tr>
268-
<tr class="font-semibold text-gray-900">
258+
</td>
259+
<td class="px-2 py-2">
260+
1h 3m
261+
</td>
262+
<td class="px-2 py-2">
263+
695<span class="text-xs">kcal</span>
264+
</td>
265+
<td class="px-2 py-2">
266+
</td>
267+
</tr>
268+
<tr class="font-semibold text-gray-900">
269269
<td class="px-2 py-2 text-right sticky left-0 bg-white">
270270
TOTAL
271271
</td>

tests/strava.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)