diff --git a/Makefile b/Makefile index e5ed6742..623f2cbd 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/fittrackee_api/fittrackee_api/activities/stats.py b/fittrackee_api/fittrackee_api/activities/stats.py index 8df8e9f3..6f840a70 100644 --- a/fittrackee_api/fittrackee_api/activities/stats.py +++ b/fittrackee_api/fittrackee_api/activities/stats.py @@ -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 diff --git a/fittrackee_api/fittrackee_api/tests/test_stats_api.py b/fittrackee_api/fittrackee_api/tests/test_stats_api.py index 025cac08..2f7f877b 100644 --- a/fittrackee_api/fittrackee_api/tests/test_stats_api.py +++ b/fittrackee_api/fittrackee_api/tests/test_stats_api.py @@ -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': {