Fixed the 14-days stat being broken.

This commit is contained in:
oslomp
2019-03-01 21:19:26 +01:00
parent 65a77079a7
commit d8c7f82c94
2 changed files with 6 additions and 10 deletions

View File

@ -1,8 +1,6 @@
from datetime import datetime, timedelta
from django.core.cache import caches
from django.shortcuts import render
from django.utils import timezone
def stats(request):
stats_data = caches['default'].get('stats')
@ -32,12 +30,12 @@ def user_stats(request):
return render(request, 'stats/user.html', data, status=status)
def age_text(last_updated):
current_age = datetime.now() - last_updated
current_age = timezone.now() - last_updated
minutes = (current_age.seconds % 3600) / 60
hours = current_age.seconds / 3600
minutestr = "minute" if minutes == 1 else "minutes"
hourstr = "hour" if hours == 1 else "hours"
if current_age < timedelta(hours=1):
if current_age < timezone.timedelta(hours=1):
return 'Stats were updated {:.0f} {} ago.'.format(minutes, minutestr)
return 'Stats were updated {:.0f} {} and {:.0f} {} ago.'.format(