Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove unused function

Roland Geidere27c55768178
diff --git a/wger/manager/api/views.py b/wger/manager/api/views.py
index 7e8bc659e..74c74a9f2 100644
--- a/wger/manager/api/views.py
+++ b/wger/manager/api/views.py
@@ -81,7 +81,6 @@ from wger.manager.models import (
)
from wger.utils.cache import CacheKeyMapper
from wger.utils.viewsets import WgerOwnerObjectModelViewSet
-from wger.weight.helpers import process_log_entries
class RoutineViewSet(viewsets.ModelViewSet):
diff --git a/wger/weight/helpers.py b/wger/weight/helpers.py
index 2965fa0b2..9503bc145 100644
--- a/wger/weight/helpers.py
+++ b/wger/weight/helpers.py
@@ -19,7 +19,6 @@ import csv
import datetime
import decimal
import io
-import json
import logging
from collections import OrderedDict
@@ -32,10 +31,8 @@ from wger.manager.models import (
WorkoutSession,
)
from wger.utils.cache import cache_mapper
-from wger.utils.helpers import DecimalJsonEncoder
from wger.weight.models import WeightEntry
-
logger = logging.getLogger(__name__)
@@ -152,56 +149,6 @@ def group_log_entries(user, year, month, day=None):
return out
-def process_log_entries(logs):
- """
- Processes and regroups a list of log entries so they can be rendered
- and passed to the D3 library to render a chart
- """
-
- entry_log = OrderedDict()
- entry_list = {}
- chart_data = []
- max_weight = {}
-
- # Group by date
- for entry in logs:
- if not entry_log.get(entry.date):
- entry_log[entry.date] = []
- entry_log[entry.date].append(entry)
-
- # Find the maximum weight per date per repetition.
- # If on a day there are several entries with the same number of
- # repetitions, but different weights, only the entry with the
- # higher weight is shown in the chart
- if not max_weight.get(entry.date):
- max_weight[entry.date] = {entry.reps: entry.weight}
-
- if not max_weight[entry.date].get(entry.reps):
- max_weight[entry.date][entry.reps] = entry.weight
-
- if entry.weight > max_weight[entry.date][entry.reps]:
- max_weight[entry.date][entry.reps] = entry.weight
-
- for entry in logs:
- if not entry_list.get(entry.reps):
- entry_list[entry.reps] = {'list': [], 'seen': []}
-
- # Only add if weight is the maximum for the day
- if entry.weight != max_weight[entry.date][entry.reps]:
- continue
- if (entry.date, entry.reps, entry.weight) in entry_list[entry.reps]['seen']:
- continue
-
- entry_list[entry.reps]['seen'].append((entry.date, entry.reps, entry.weight))
- entry_list[entry.reps]['list'].append(
- {'date': entry.date, 'weight': entry.weight, 'reps': entry.reps}
- )
- for rep in entry_list:
- chart_data.append(entry_list[rep]['list'])
-
- return entry_log, json.dumps(chart_data, cls=DecimalJsonEncoder)
-
-
def get_last_entries(user, amount=5):
"""
Get the last weight entries as well as the difference to the last