Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Filter out non-weight units as well as non-repetitions.

Roland Geidere9f90209ac2e
diff --git a/wger/manager/templates/workout/log.html b/wger/manager/templates/workout/log.html
index 408c7bb49..6cd49396d 100644
--- a/wger/manager/templates/workout/log.html
+++ b/wger/manager/templates/workout/log.html
@@ -124,4 +124,7 @@ entry.{% endblocktrans %}</p>
same number of repetitions, but different weights, only the entry with the
higher weight is shown in the diagram.{% endblocktrans %}</p>
+<p>{% blocktrans %}Note that only entries with a weight unit (kg or lb) and
+repetitions are charted, other combinations such as time or until failure
+are ignored here.{% endblocktrans %}</p>
{% endblock %}
diff --git a/wger/manager/views/log.py b/wger/manager/views/log.py
index 7df167e04..bda05d97c 100644
--- a/wger/manager/views/log.py
+++ b/wger/manager/views/log.py
@@ -23,12 +23,10 @@ from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse, reverse_lazy
-from django.utils import formats
from django.utils.translation import ugettext_lazy, ugettext as _
from django.forms.models import modelformset_factory
from django.views.generic import (
UpdateView,
- CreateView,
DetailView,
DeleteView
)
@@ -246,8 +244,18 @@ class WorkoutLogDetailView(DetailView, WgerPermissionMixin):
exercise_id = exercise_list['obj'].id
exercise_log[exercise_id] = []
+ # Filter the logs for user and exclude all units that are not weight
+ #
+ # TODO: add the repetition_unit to the filter. For some reason (bug
+ # in django? DB problems?) when adding the filter there, the
+ # execution time explodes. The weight unit filter works as
+ # expected. Also, adding the unit IDs to the exclude list
+ # also has the disadvantage that if new ones are added in a
+ # local instance, they could "slip" through.
logs = exercise_list['obj'].workoutlog_set.filter(user=self.owner_user,
- workout=self.object)
+ weight_unit__in=(1, 2),
+ workout=self.object) \
+ .exclude(repetition_unit_id__in=(2, 3, 4, 5, 6, 7, 8))
entry_log, chart_data = process_log_entries(logs)
if entry_log:
exercise_log[exercise_list['obj'].id].append(entry_log)