fix stats by week

This commit is contained in:
Sam 2018-07-04 12:00:34 +02:00
parent 54375e0576
commit 88382d72d5
3 changed files with 6 additions and 4 deletions

View File

@ -67,7 +67,7 @@ test-e2e: init-db
$(NPM) test
test-python:
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report term-missing
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report term-missing $(PYTEST_ARGS)
test-python-xml:
$(PYTEST) fittrackee_api --cov-config .coveragerc --cov=fittrackee_api --cov-report xml

View File

@ -76,7 +76,9 @@ def get_activities(user_id, filter_type):
else:
if time == 'week':
activity_date = activity.activity_date - timedelta(
days=activity.activity_date.isoweekday()
days=(activity.activity_date.isoweekday()
if activity.activity_date.isoweekday() < 7
else 0)
)
time_period = datetime.strftime(activity_date, "%Y-%m-%d")
elif time == 'weekm': # week start Monday

View File

@ -684,7 +684,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 1600
}
},
'2018-03-25':
'2018-04-01':
{
'1':
{
@ -738,7 +738,7 @@ def test_get_stats_by_week_all_activities_week_13(
assert 'success' in data['status']
assert data['data']['statistics'] == \
{
'2018-03-25':
'2018-04-01':
{
'1':
{