Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove dead code

Roland Geider937ed1624051
diff --git a/wger/core/management/commands/clear-cache.py b/wger/core/management/commands/clear-cache.py
index 3030fae32..7adfdbcda 100644
--- a/wger/core/management/commands/clear-cache.py
+++ b/wger/core/management/commands/clear-cache.py
@@ -22,7 +22,6 @@ from django.core.management.base import (
# wger
from wger.manager.models import WorkoutLog
-from wger.utils.cache import reset_workout_log_cache
class Command(BaseCommand):
@@ -81,7 +80,6 @@ class Command(BaseCommand):
):
if int(options['verbosity']) >= 3:
self.stdout.write(f' Month {entry.month}')
- reset_workout_log_cache(user.id, entry.year, entry.month)
for day in WorkoutLog.objects.filter(
user=user,
date__year=entry.year,
@@ -89,7 +87,6 @@ class Command(BaseCommand):
).dates('date', 'day'):
if int(options['verbosity']) >= 3:
self.stdout.write(f' Day {day.day}')
- reset_workout_log_cache(user.id, entry.year, entry.month, day)
# Nuclear option, clear all
if options['clear_all']:
diff --git a/wger/manager/models/log.py b/wger/manager/models/log.py
index 6688eec82..9c4ee113e 100644
--- a/wger/manager/models/log.py
+++ b/wger/manager/models/log.py
@@ -36,7 +36,6 @@ from wger.manager.validators import (
NullMinValueValidator,
validate_rir,
)
-from wger.utils.cache import reset_workout_log_cache
class WorkoutLog(models.Model):
@@ -263,14 +262,6 @@ class WorkoutLog(models.Model):
routine=self.routine,
)[0]
- # Reset cache
- reset_workout_log_cache(
- self.user_id,
- self.session.date.year,
- self.session.date.month,
- self.session.date.day,
- )
-
# If the user of next_log is not this user, remove foreign key
if self.next_log and self.next_log.user != self.user:
self.next_log = None
@@ -282,19 +273,3 @@ class WorkoutLog(models.Model):
# Save to db
super().save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset cache
- """
- try:
- reset_workout_log_cache(
- self.user_id,
- self.session.date.year,
- self.session.date.month,
- self.session.date.day,
- )
- # Catch case when there is no session -> RelatedObjectDoesNotExist
- except WorkoutSession.DoesNotExist:
- pass
- super(WorkoutLog, self).delete(*args, **kwargs)
diff --git a/wger/manager/models/session.py b/wger/manager/models/session.py
index 053845b7b..c14e7b75f 100644
--- a/wger/manager/models/session.py
+++ b/wger/manager/models/session.py
@@ -23,9 +23,6 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
-# wger
-from wger.utils.cache import reset_workout_log_cache
-
class WorkoutSession(models.Model):
"""
@@ -149,17 +146,3 @@ class WorkoutSession(models.Model):
Returns the object that has owner information
"""
return self
-
- def save(self, *args, **kwargs):
- """
- Reset cache
- """
- reset_workout_log_cache(self.user_id, self.date.year, self.date.month)
- super().save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset cache
- """
- reset_workout_log_cache(self.user_id, self.date.year, self.date.month)
- super().delete(*args, **kwargs)
diff --git a/wger/utils/cache.py b/wger/utils/cache.py
index ad79377b6..78ffecd95 100644
--- a/wger/utils/cache.py
+++ b/wger/utils/cache.py
@@ -27,18 +27,6 @@ def reset_exercise_api_cache(uuid: str):
cache.delete(CacheKeyMapper.get_exercise_api_key(uuid))
-def reset_workout_log_cache(user_pk, year, month, day=None):
- """
- Resets the cached workout logs
- """
-
- log_hash = hash((user_pk, year, month))
- cache.delete(cache_mapper.get_workout_log_list(log_hash))
-
- log_hash = hash((user_pk, year, month, day))
- cache.delete(cache_mapper.get_workout_log_list(log_hash))
-
-
class CacheKeyMapper:
"""
Simple class for mapping the cache keys of different objects
@@ -56,12 +44,6 @@ class CacheKeyMapper:
"""
return f'language-{self.get_pk(param)}'
- def get_workout_log_list(self, hash_value):
- """
- Return the workout canonical representation
- """
- return f'workout-log-hash-{hash_value}'
-
def get_nutrition_cache_by_key(self, params):
"""
get nutritional info values canonical representation using primary key.