Fix moodstats signature

Remove unused variables
Fix time selection for CSV
This commit is contained in:
Kumi 2021-02-26 07:38:17 +01:00
parent e7f0e07a99
commit 8d75d9b342
2 changed files with 13 additions and 10 deletions

View file

@ -9,12 +9,9 @@ from dateutil.relativedelta import relativedelta
from .models import Status, Mood from .models import Status, Mood
def moodstats(user, mindate=None, maxdate=None, days=7): def moodstats(user):
hv.extension('bokeh') hv.extension('bokeh')
maxdate = maxdate or timezone.now()
mindate = mindate or (maxdate - relativedelta(days=days))
tooltips = [ tooltips = [
('Date', '@date{%F %H:%M}'), ('Date', '@date{%F %H:%M}'),
('Value', '@value') ('Value', '@value')
@ -60,9 +57,6 @@ def moodstats(user, mindate=None, maxdate=None, days=7):
return output return output
def activitystats(user): def activitystats(user):
maxdate = maxdate or timezone.now()
mindate = mindate or (maxdate - relativedelta(days=days))
output = {} output = {}
for status in Status.objects.filter(user=user): for status in Status.objects.filter(user=user):

View file

@ -356,14 +356,23 @@ class MoodCSVView(LoginRequiredMixin, View):
startdate = request.GET.get("start") startdate = request.GET.get("start")
enddate = request.GET.get("end") enddate = request.GET.get("end")
maxdate = None
mindate = None
if enddate: if enddate:
maxdate = datetime.strptime(enddate, "%Y-%m-%d") maxdate = datetime.strptime(enddate, "%Y-%m-%d")
else:
maxdate = timezone.now() if not startdate:
mindate = maxdate - relativedelta.relativedelta(weeks=1)
if startdate: if startdate:
mindate = datetime.strptime(startdate, "%Y-%m-%d") mindate = datetime.strptime(startdate, "%Y-%m-%d")
else:
if not enddate:
maxdate = mindate + relativedelta.relativedelta(weeks=1)
if not maxdate:
maxdate = timezone.now()
mindate = maxdate - relativedelta.relativedelta(weeks=1) mindate = maxdate - relativedelta.relativedelta(weeks=1)
output = "date,value" output = "date,value"