API & Client: chart with month activities on dashboard - #9 (WIP)

This commit is contained in:
Sam
2018-06-06 20:17:37 +02:00
parent 0128985664
commit 30f112c094
11 changed files with 235 additions and 36 deletions

View File

@ -70,14 +70,12 @@ def get_activities(user_id, type):
activity_date = activity.activity_date - timedelta(
days=activity.activity_date.isoweekday()
)
time_period = datetime.strftime(activity_date,
"%Y-%m-%d_W%U")
time_period = datetime.strftime(activity_date, "%Y-%m-%d")
elif time == 'weekm': # week start Monday
activity_date = activity.activity_date - timedelta(
days=activity.activity_date.weekday()
)
time_period = datetime.strftime(activity_date,
"%Y-%m-%d_W%W")
time_period = datetime.strftime(activity_date, "%Y-%m-%d")
elif time == 'month':
time_period = datetime.strftime(activity.activity_date, "%Y-%m") # noqa
elif time == 'year' or not time:

View File

@ -468,7 +468,7 @@ def test_get_stats_by_week_all_activities(
assert 'success' in data['status']
assert data['data']['statistics'] == \
{
'2017-03-19_W12':
'2017-03-19':
{
'1':
{
@ -477,7 +477,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 1024
}
},
'2017-05-28_W22':
'2017-05-28':
{
'1':
{
@ -486,7 +486,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 3456
}
},
'2017-12-31_W53':
'2017-12-31':
{
'1':
{
@ -495,7 +495,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 1024
}
},
'2018-02-18_W07':
'2018-02-18':
{
'1':
{
@ -504,7 +504,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 1600
}
},
'2018-03-25_W12':
'2018-03-25':
{
'1':
{
@ -519,7 +519,7 @@ def test_get_stats_by_week_all_activities(
'total_duration': 6000
}
},
'2018-05-06_W18':
'2018-05-06':
{
'1':
{
@ -558,7 +558,7 @@ def test_get_stats_by_week_all_activities_week_13(
assert 'success' in data['status']
assert data['data']['statistics'] == \
{
'2018-03-25_W12':
'2018-03-25':
{
'1':
{
@ -603,7 +603,7 @@ def test_get_stats_by_weekm_all_activities(
assert 'success' in data['status']
assert data['data']['statistics'] == \
{
'2017-03-20_W12':
'2017-03-20':
{
'1':
{
@ -612,7 +612,7 @@ def test_get_stats_by_weekm_all_activities(
'total_duration': 1024
}
},
'2017-05-29_W22':
'2017-05-29':
{
'1':
{
@ -621,7 +621,7 @@ def test_get_stats_by_weekm_all_activities(
'total_duration': 3456
}
},
'2018-01-01_W01':
'2018-01-01':
{
'1':
{
@ -630,7 +630,7 @@ def test_get_stats_by_weekm_all_activities(
'total_duration': 1024
}
},
'2018-02-19_W08':
'2018-02-19':
{
'1':
{
@ -639,7 +639,7 @@ def test_get_stats_by_weekm_all_activities(
'total_duration': 1600
}
},
'2018-03-26_W13':
'2018-03-26':
{
'1':
{
@ -654,7 +654,7 @@ def test_get_stats_by_weekm_all_activities(
'total_duration': 6000
}
},
'2018-05-07_W19':
'2018-05-07':
{
'1':
{
@ -693,7 +693,7 @@ def test_get_stats_by_weekm_all_activities_week_13(
assert 'success' in data['status']
assert data['data']['statistics'] == \
{
'2018-03-26_W13':
'2018-03-26':
{
'1':
{