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 539ee03709
commit 5cef852510
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
def moodstats(user, mindate=None, maxdate=None, days=7):
def moodstats(user):
hv.extension('bokeh')
maxdate = maxdate or timezone.now()
mindate = mindate or (maxdate - relativedelta(days=days))
tooltips = [
('Date', '@date{%F %H:%M}'),
('Value', '@value')
@ -60,9 +57,6 @@ def moodstats(user, mindate=None, maxdate=None, days=7):
return output
def activitystats(user):
maxdate = maxdate or timezone.now()
mindate = mindate or (maxdate - relativedelta(days=days))
output = {}
for status in Status.objects.filter(user=user):

View file

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