fix: show today's data in line chart and fix total energy points

This commit is contained in:
Prssanna Desai 2019-08-14 14:36:39 +05:30
parent d71e95c5b5
commit 7bcdb69baa
2 changed files with 4 additions and 3 deletions

View file

@ -5,6 +5,7 @@
from __future__ import unicode_literals
import frappe, json
from frappe import _
import datetime
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
from frappe.utils import nowdate, add_to_date, getdate, get_last_day, formatdate
from frappe.model.document import Document
@ -24,7 +25,7 @@ def get(chart, no_cache=None, from_date=None, to_date=None, refresh = None):
if not from_date:
from_date = get_from_date_from_timespan(to_date, timespan)
if not to_date:
to_date = nowdate()
to_date = datetime.datetime.now()
# get conditions from filters
conditions, values = frappe.db.build_conditions(filters)
@ -79,7 +80,7 @@ def convert_to_dates(data, timegrain):
result = []
for d in data:
if timegrain == 'Daily':
result.append([add_to_date('{:d}-01-01'.format(int(d[0])), days = d[1]), d[2]])
result.append([add_to_date('{:d}-01-01'.format(int(d[0])), days = d[1] - 1), d[2]])
elif timegrain == 'Weekly':
result.append([add_to_date(add_to_date('{:d}-01-01'.format(int(d[0])), weeks = d[1] + 1), days = -1), d[2]])
elif timegrain == 'Monthly':

View file

@ -403,7 +403,7 @@ class UserProfile {
user: this.user_id,
}
).then(r => {
if (r.length) {
if (r) {
this.energy_points = r[this.user_id].energy_points;
this.review_points = r[this.user_id].review_points;
}