fix merge conflicts

This commit is contained in:
oslomp
2019-01-30 15:55:10 +01:00
31 changed files with 712 additions and 137 deletions

View File

@ -5,29 +5,30 @@ from django.shortcuts import render
def stats(request):
stats = caches['default'].get('stats')
stats_data = caches['default'].get('stats')
status = 503
current_age = None
current_age_text = None
if stats:
if stats_data:
status = 200
current_age_text = age_text(stats['last_updated'])
current_age_text = age_text(stats_data['last_updated'])
data = {'stats': stats, 'current_age': current_age, 'current_age_text': current_age_text}
data = {'stats': stats_data, 'current_age': current_age, 'current_age_text': current_age_text}
return render(request, 'stats/stats.html', data, status=status)
def user_stats(request):
stats = caches['userstats'].get('userstats_{}'.format(request.user.id))
stats_data = caches['default'].get('userstats_{}'.format(request.user.id))
status = 503
current_age = None
current_age_text = None
if stats:
if stats_data:
status = 200
current_age_text = age_text(stats['last_updated'])
current_age_text = age_text(stats_data['last_updated'])
data = {'stats': stats, 'current_age': current_age, 'current_age_text': current_age_text}
data = {'stats': stats_data, 'current_age': current_age, 'current_age_text': current_age_text}
return render(request, 'stats/user.html', data, status=status)
def age_text(last_updated):
@ -38,7 +39,6 @@ def age_text(last_updated):
hourstr = "hour" if hours == 1 else "hours"
if current_age < timedelta(hours=1):
return 'Stats were updated {:.0f} {} ago.'.format(minutes, minutestr)
else:
return 'Stats were updated {:.0f} {} and {:.0f} {} ago.'.format(
hours, hourstr, minutes, minutestr)
return 'Stats were updated {:.0f} {} and {:.0f} {} ago.'.format(
hours, hourstr, minutes, minutestr)