API & Client - display only sports with activities on statistics
This commit is contained in:
parent
189a1bc35f
commit
0c7cefba13
@ -323,6 +323,11 @@
|
|||||||
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
||||||
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||||
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
||||||
|
<span class="nt">"sports_list"</span><span class="p">:</span> <span class="p">[</span>
|
||||||
|
<span class="mi">1</span><span class="p">,</span>
|
||||||
|
<span class="mi">4</span><span class="p">,</span>
|
||||||
|
<span class="mi">6</span>
|
||||||
|
<span class="p">],</span>
|
||||||
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
||||||
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
||||||
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
||||||
@ -381,6 +386,11 @@
|
|||||||
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
||||||
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||||
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
||||||
|
<span class="nt">"sports_list"</span><span class="p">:</span> <span class="p">[</span>
|
||||||
|
<span class="mi">1</span><span class="p">,</span>
|
||||||
|
<span class="mi">4</span><span class="p">,</span>
|
||||||
|
<span class="mi">6</span>
|
||||||
|
<span class="p">],</span>
|
||||||
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
||||||
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
||||||
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
||||||
|
@ -154,6 +154,11 @@
|
|||||||
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
||||||
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||||
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
||||||
|
<span class="nt">"sports_list"</span><span class="p">:</span> <span class="p">[</span>
|
||||||
|
<span class="mi">1</span><span class="p">,</span>
|
||||||
|
<span class="mi">4</span><span class="p">,</span>
|
||||||
|
<span class="mi">6</span>
|
||||||
|
<span class="p">],</span>
|
||||||
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
||||||
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
||||||
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
||||||
@ -172,6 +177,7 @@
|
|||||||
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||||
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||||
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
||||||
|
<span class="nt">"sports_list"</span><span class="p">:</span> <span class="p">[],</span>
|
||||||
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
||||||
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||||
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"0:00:00"</span><span class="p">,</span>
|
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"0:00:00"</span><span class="p">,</span>
|
||||||
@ -235,6 +241,11 @@
|
|||||||
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
<span class="nt">"nb_activities"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
|
||||||
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
<span class="nt">"nb_sports"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||||
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
<span class="nt">"picture"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
|
||||||
|
<span class="nt">"sports_list"</span><span class="p">:</span> <span class="p">[</span>
|
||||||
|
<span class="mi">1</span><span class="p">,</span>
|
||||||
|
<span class="mi">4</span><span class="p">,</span>
|
||||||
|
<span class="mi">6</span>
|
||||||
|
<span class="p">],</span>
|
||||||
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
<span class="nt">"timezone"</span><span class="p">:</span> <span class="s2">"Europe/Paris"</span><span class="p">,</span>
|
||||||
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
<span class="nt">"total_distance"</span><span class="p">:</span> <span class="mf">67.895</span><span class="p">,</span>
|
||||||
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
<span class="nt">"total_duration"</span><span class="p">:</span> <span class="s2">"6:50:27"</span><span class="p">,</span>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -428,6 +428,7 @@ def test_user_profile_minimal(app, user_1):
|
|||||||
assert data['data']['language'] is None
|
assert data['data']['language'] is None
|
||||||
assert data['data']['nb_activities'] == 0
|
assert data['data']['nb_activities'] == 0
|
||||||
assert data['data']['nb_sports'] == 0
|
assert data['data']['nb_sports'] == 0
|
||||||
|
assert data['data']['sports_list'] == []
|
||||||
assert data['data']['total_distance'] == 0
|
assert data['data']['total_distance'] == 0
|
||||||
assert data['data']['total_duration'] == '0:00:00'
|
assert data['data']['total_duration'] == '0:00:00'
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
@ -464,6 +465,7 @@ def test_user_profile_full(app, user_1_full):
|
|||||||
assert data['data']['language'] == 'en'
|
assert data['data']['language'] == 'en'
|
||||||
assert data['data']['nb_activities'] == 0
|
assert data['data']['nb_activities'] == 0
|
||||||
assert data['data']['nb_sports'] == 0
|
assert data['data']['nb_sports'] == 0
|
||||||
|
assert data['data']['sports_list'] == []
|
||||||
assert data['data']['total_distance'] == 0
|
assert data['data']['total_distance'] == 0
|
||||||
assert data['data']['total_duration'] == '0:00:00'
|
assert data['data']['total_duration'] == '0:00:00'
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
@ -500,6 +502,7 @@ def test_user_profile_with_activities(
|
|||||||
assert data['data']['timezone'] is None
|
assert data['data']['timezone'] is None
|
||||||
assert data['data']['nb_activities'] == 2
|
assert data['data']['nb_activities'] == 2
|
||||||
assert data['data']['nb_sports'] == 2
|
assert data['data']['nb_sports'] == 2
|
||||||
|
assert data['data']['sports_list'] == [1, 2]
|
||||||
assert data['data']['total_distance'] == 22
|
assert data['data']['total_distance'] == 22
|
||||||
assert data['data']['total_duration'] == '1:57:04'
|
assert data['data']['total_duration'] == '1:57:04'
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
@ -563,6 +566,7 @@ def test_user_profile_valid_update(app, user_1):
|
|||||||
assert data['data']['language'] == 'fr'
|
assert data['data']['language'] == 'fr'
|
||||||
assert data['data']['nb_activities'] == 0
|
assert data['data']['nb_activities'] == 0
|
||||||
assert data['data']['nb_sports'] == 0
|
assert data['data']['nb_sports'] == 0
|
||||||
|
assert data['data']['sports_list'] == []
|
||||||
assert data['data']['total_distance'] == 0
|
assert data['data']['total_distance'] == 0
|
||||||
assert data['data']['total_duration'] == '0:00:00'
|
assert data['data']['total_duration'] == '0:00:00'
|
||||||
|
|
||||||
@ -612,6 +616,7 @@ def test_user_profile_valid_update_without_password(app, user_1):
|
|||||||
assert data['data']['language'] == 'fr'
|
assert data['data']['language'] == 'fr'
|
||||||
assert data['data']['nb_activities'] == 0
|
assert data['data']['nb_activities'] == 0
|
||||||
assert data['data']['nb_sports'] == 0
|
assert data['data']['nb_sports'] == 0
|
||||||
|
assert data['data']['sports_list'] == []
|
||||||
assert data['data']['total_distance'] == 0
|
assert data['data']['total_distance'] == 0
|
||||||
assert data['data']['total_duration'] == '0:00:00'
|
assert data['data']['total_duration'] == '0:00:00'
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ def test_single_user(app, user_1):
|
|||||||
assert data['data']['language'] is None
|
assert data['data']['language'] is None
|
||||||
assert data['data']['nb_activities'] == 0
|
assert data['data']['nb_activities'] == 0
|
||||||
assert data['data']['nb_sports'] == 0
|
assert data['data']['nb_sports'] == 0
|
||||||
|
assert data['data']['sports_list'] == []
|
||||||
assert data['data']['total_distance'] == 0
|
assert data['data']['total_distance'] == 0
|
||||||
assert data['data']['total_duration'] == '0:00:00'
|
assert data['data']['total_duration'] == '0:00:00'
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ def test_single_user_with_activities(
|
|||||||
assert data['data']['language'] is None
|
assert data['data']['language'] is None
|
||||||
assert data['data']['nb_activities'] == 2
|
assert data['data']['nb_activities'] == 2
|
||||||
assert data['data']['nb_sports'] == 2
|
assert data['data']['nb_sports'] == 2
|
||||||
|
assert data['data']['sports_list'] == [1, 2]
|
||||||
assert data['data']['total_distance'] == 22
|
assert data['data']['total_distance'] == 22
|
||||||
assert data['data']['total_duration'] == '1:57:04'
|
assert data['data']['total_duration'] == '1:57:04'
|
||||||
|
|
||||||
@ -180,6 +182,7 @@ def test_users_list(app, user_1, user_2, user_3):
|
|||||||
assert data['data']['users'][0]['language'] is None
|
assert data['data']['users'][0]['language'] is None
|
||||||
assert data['data']['users'][0]['nb_activities'] == 0
|
assert data['data']['users'][0]['nb_activities'] == 0
|
||||||
assert data['data']['users'][0]['nb_sports'] == 0
|
assert data['data']['users'][0]['nb_sports'] == 0
|
||||||
|
assert data['data']['users'][0]['sports_list'] == []
|
||||||
assert data['data']['users'][0]['total_distance'] == 0
|
assert data['data']['users'][0]['total_distance'] == 0
|
||||||
assert data['data']['users'][0]['total_duration'] == '0:00:00'
|
assert data['data']['users'][0]['total_duration'] == '0:00:00'
|
||||||
assert data['data']['users'][1]['timezone'] is None
|
assert data['data']['users'][1]['timezone'] is None
|
||||||
@ -187,6 +190,7 @@ def test_users_list(app, user_1, user_2, user_3):
|
|||||||
assert data['data']['users'][1]['language'] is None
|
assert data['data']['users'][1]['language'] is None
|
||||||
assert data['data']['users'][1]['nb_activities'] == 0
|
assert data['data']['users'][1]['nb_activities'] == 0
|
||||||
assert data['data']['users'][1]['nb_sports'] == 0
|
assert data['data']['users'][1]['nb_sports'] == 0
|
||||||
|
assert data['data']['users'][1]['sports_list'] == []
|
||||||
assert data['data']['users'][1]['total_distance'] == 0
|
assert data['data']['users'][1]['total_distance'] == 0
|
||||||
assert data['data']['users'][1]['total_duration'] == '0:00:00'
|
assert data['data']['users'][1]['total_duration'] == '0:00:00'
|
||||||
assert data['data']['users'][2]['timezone'] is None
|
assert data['data']['users'][2]['timezone'] is None
|
||||||
@ -194,6 +198,7 @@ def test_users_list(app, user_1, user_2, user_3):
|
|||||||
assert data['data']['users'][2]['language'] is None
|
assert data['data']['users'][2]['language'] is None
|
||||||
assert data['data']['users'][2]['nb_activities'] == 0
|
assert data['data']['users'][2]['nb_activities'] == 0
|
||||||
assert data['data']['users'][2]['nb_sports'] == 0
|
assert data['data']['users'][2]['nb_sports'] == 0
|
||||||
|
assert data['data']['users'][2]['sports_list'] == []
|
||||||
assert data['data']['users'][2]['total_distance'] == 0
|
assert data['data']['users'][2]['total_distance'] == 0
|
||||||
assert data['data']['users'][2]['total_duration'] == '0:00:00'
|
assert data['data']['users'][2]['total_duration'] == '0:00:00'
|
||||||
|
|
||||||
@ -242,18 +247,21 @@ def test_users_list_with_activities(
|
|||||||
assert data['data']['users'][0]['weekm'] is False
|
assert data['data']['users'][0]['weekm'] is False
|
||||||
assert data['data']['users'][0]['nb_activities'] == 2
|
assert data['data']['users'][0]['nb_activities'] == 2
|
||||||
assert data['data']['users'][0]['nb_sports'] == 2
|
assert data['data']['users'][0]['nb_sports'] == 2
|
||||||
|
assert data['data']['users'][0]['sports_list'] == [1, 2]
|
||||||
assert data['data']['users'][0]['total_distance'] == 22.0
|
assert data['data']['users'][0]['total_distance'] == 22.0
|
||||||
assert data['data']['users'][0]['total_duration'] == '1:57:04'
|
assert data['data']['users'][0]['total_duration'] == '1:57:04'
|
||||||
assert data['data']['users'][1]['timezone'] is None
|
assert data['data']['users'][1]['timezone'] is None
|
||||||
assert data['data']['users'][1]['weekm'] is False
|
assert data['data']['users'][1]['weekm'] is False
|
||||||
assert data['data']['users'][1]['nb_activities'] == 1
|
assert data['data']['users'][1]['nb_activities'] == 1
|
||||||
assert data['data']['users'][1]['nb_sports'] == 1
|
assert data['data']['users'][1]['nb_sports'] == 1
|
||||||
|
assert data['data']['users'][1]['sports_list'] == [1]
|
||||||
assert data['data']['users'][1]['total_distance'] == 15
|
assert data['data']['users'][1]['total_distance'] == 15
|
||||||
assert data['data']['users'][1]['total_duration'] == '1:00:00'
|
assert data['data']['users'][1]['total_duration'] == '1:00:00'
|
||||||
assert data['data']['users'][2]['timezone'] is None
|
assert data['data']['users'][2]['timezone'] is None
|
||||||
assert data['data']['users'][2]['weekm'] is True
|
assert data['data']['users'][2]['weekm'] is True
|
||||||
assert data['data']['users'][2]['nb_activities'] == 0
|
assert data['data']['users'][2]['nb_activities'] == 0
|
||||||
assert data['data']['users'][2]['nb_sports'] == 0
|
assert data['data']['users'][2]['nb_sports'] == 0
|
||||||
|
assert data['data']['users'][2]['sports_list'] == []
|
||||||
assert data['data']['users'][2]['total_distance'] == 0
|
assert data['data']['users'][2]['total_distance'] == 0
|
||||||
assert data['data']['users'][2]['total_duration'] == '0:00:00'
|
assert data['data']['users'][2]['total_duration'] == '0:00:00'
|
||||||
|
|
||||||
|
@ -337,6 +337,11 @@ def get_user_status(user_id):
|
|||||||
"nb_activities": 6,
|
"nb_activities": 6,
|
||||||
"nb_sports": 3,
|
"nb_sports": 3,
|
||||||
"picture": false,
|
"picture": false,
|
||||||
|
"sports_list": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
6
|
||||||
|
],
|
||||||
"timezone": "Europe/Paris",
|
"timezone": "Europe/Paris",
|
||||||
"total_distance": 67.895,
|
"total_distance": 67.895,
|
||||||
"total_duration": "6:50:27",
|
"total_duration": "6:50:27",
|
||||||
@ -395,6 +400,11 @@ def edit_user(user_id):
|
|||||||
"nb_activities": 6,
|
"nb_activities": 6,
|
||||||
"nb_sports": 3,
|
"nb_sports": 3,
|
||||||
"picture": false,
|
"picture": false,
|
||||||
|
"sports_list": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
6
|
||||||
|
],
|
||||||
"timezone": "Europe/Paris",
|
"timezone": "Europe/Paris",
|
||||||
"total_distance": 67.895,
|
"total_distance": 67.895,
|
||||||
"total_duration": "6:50:27",
|
"total_duration": "6:50:27",
|
||||||
|
@ -96,9 +96,10 @@ class User(db.Model):
|
|||||||
total = (None, None)
|
total = (None, None)
|
||||||
if nb_activity > 0:
|
if nb_activity > 0:
|
||||||
sports = (
|
sports = (
|
||||||
db.session.query(func.count(Activity.sport_id))
|
db.session.query(Activity.sport_id)
|
||||||
.filter(Activity.user_id == self.id)
|
.filter(Activity.user_id == self.id)
|
||||||
.group_by(Activity.sport_id)
|
.group_by(Activity.sport_id)
|
||||||
|
.order_by(Activity.sport_id)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
total = (
|
total = (
|
||||||
@ -125,6 +126,9 @@ class User(db.Model):
|
|||||||
'language': self.language,
|
'language': self.language,
|
||||||
'nb_activities': nb_activity,
|
'nb_activities': nb_activity,
|
||||||
'nb_sports': len(sports),
|
'nb_sports': len(sports),
|
||||||
|
'sports_list': [
|
||||||
|
sport for sportslist in sports for sport in sportslist
|
||||||
|
],
|
||||||
'total_distance': float(total[0]) if total[0] else 0,
|
'total_distance': float(total[0]) if total[0] else 0,
|
||||||
'total_duration': str(total[1]) if total[1] else "0:00:00",
|
'total_duration': str(total[1]) if total[1] else "0:00:00",
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,11 @@ def get_users(auth_user_id):
|
|||||||
"nb_activities": 6,
|
"nb_activities": 6,
|
||||||
"nb_sports": 3,
|
"nb_sports": 3,
|
||||||
"picture": false,
|
"picture": false,
|
||||||
|
"sports_list": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
6
|
||||||
|
],
|
||||||
"timezone": "Europe/Paris",
|
"timezone": "Europe/Paris",
|
||||||
"total_distance": 67.895,
|
"total_distance": 67.895,
|
||||||
"total_duration": "6:50:27",
|
"total_duration": "6:50:27",
|
||||||
@ -61,6 +66,7 @@ def get_users(auth_user_id):
|
|||||||
"nb_activities": 0,
|
"nb_activities": 0,
|
||||||
"nb_sports": 0,
|
"nb_sports": 0,
|
||||||
"picture": false,
|
"picture": false,
|
||||||
|
"sports_list": [],
|
||||||
"timezone": "Europe/Paris",
|
"timezone": "Europe/Paris",
|
||||||
"total_distance": 0,
|
"total_distance": 0,
|
||||||
"total_duration": "0:00:00",
|
"total_duration": "0:00:00",
|
||||||
@ -124,6 +130,11 @@ def get_single_user(auth_user_id, user_id):
|
|||||||
"nb_activities": 6,
|
"nb_activities": 6,
|
||||||
"nb_sports": 3,
|
"nb_sports": 3,
|
||||||
"picture": false,
|
"picture": false,
|
||||||
|
"sports_list": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
6
|
||||||
|
],
|
||||||
"timezone": "Europe/Paris",
|
"timezone": "Europe/Paris",
|
||||||
"total_distance": 67.895,
|
"total_distance": 67.895,
|
||||||
"total_duration": "6:50:27",
|
"total_duration": "6:50:27",
|
||||||
|
@ -403,6 +403,11 @@ label {
|
|||||||
max-height: 45px;
|
max-height: 45px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stats-disabled {
|
||||||
|
opacity: 0.3;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.time-frames {
|
.time-frames {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
@ -17,8 +17,9 @@ import { Helmet } from 'react-helmet'
|
|||||||
import { withTranslation } from 'react-i18next'
|
import { withTranslation } from 'react-i18next'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import { activityColors, translateSports } from '../../utils/activities'
|
import NoActivities from '../Common/NoActivities'
|
||||||
import Stats from '../Common/Stats'
|
import Stats from '../Common/Stats'
|
||||||
|
import { activityColors, translateSports } from '../../utils/activities'
|
||||||
|
|
||||||
const durations = ['week', 'month', 'year']
|
const durations = ['week', 'month', 'year']
|
||||||
|
|
||||||
@ -115,8 +116,11 @@ class Statistics extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { displayedSports, statsParams } = this.state
|
const { displayedSports, statsParams } = this.state
|
||||||
const { sports, t } = this.props
|
const { sports, t, user } = this.props
|
||||||
const translatedSports = translateSports(sports, t)
|
const translatedSports = translateSports(
|
||||||
|
sports.filter(sport => user.sports_list.includes(sport.id)),
|
||||||
|
t
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
@ -125,7 +129,11 @@ class Statistics extends React.Component {
|
|||||||
<div className="container dashboard">
|
<div className="container dashboard">
|
||||||
<div className="card activity-card">
|
<div className="card activity-card">
|
||||||
<div className="card-header">{t('statistics:Statistics')}</div>
|
<div className="card-header">{t('statistics:Statistics')}</div>
|
||||||
<div className="card-body">
|
<div
|
||||||
|
className={`card-body${
|
||||||
|
user.nb_activities === 0 ? ' stats-disabled' : ''
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<div className="chart-filters row">
|
<div className="chart-filters row">
|
||||||
<div className="col chart-arrows">
|
<div className="col chart-arrows">
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
@ -185,6 +193,7 @@ class Statistics extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{user.nb_activities === 0 && <NoActivities t={t} />}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@ -194,5 +203,6 @@ class Statistics extends React.Component {
|
|||||||
export default withTranslation()(
|
export default withTranslation()(
|
||||||
connect(state => ({
|
connect(state => ({
|
||||||
sports: state.sports.data,
|
sports: state.sports.data,
|
||||||
|
user: state.user,
|
||||||
}))(Statistics)
|
}))(Statistics)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user