diff --git a/docs/api/activities.html b/docs/api/activities.html index bcbc5b64..dd310190 100644 --- a/docs/api/activities.html +++ b/docs/api/activities.html @@ -179,7 +179,7 @@ "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -188,7 +188,7 @@ "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -197,7 +197,7 @@ "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -206,14 +206,14 @@ "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -324,7 +324,7 @@ "segments": [], "sport_id": 1, "title": "biking on sunday morning", - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -420,7 +420,7 @@ "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -429,7 +429,7 @@ "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -438,7 +438,7 @@ "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -447,14 +447,14 @@ "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -548,7 +548,7 @@ "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -557,7 +557,7 @@ "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -566,7 +566,7 @@ "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -575,14 +575,14 @@ "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -673,7 +673,7 @@ "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -682,7 +682,7 @@ "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -691,7 +691,7 @@ "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -700,14 +700,14 @@ "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false diff --git a/docs/api/records.html b/docs/api/records.html index 1f6f7cfd..0bf15637 100644 --- a/docs/api/records.html +++ b/docs/api/records.html @@ -159,7 +159,7 @@ "id": 9, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 }, { @@ -168,7 +168,7 @@ "id": 10, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 }, { @@ -177,7 +177,7 @@ "id": 11, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "1:01:00" }, { @@ -186,7 +186,7 @@ "id": 12, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 } ] diff --git a/docs/api/stats.html b/docs/api/stats.html index abbeb6b9..e7213945 100644 --- a/docs/api/stats.html +++ b/docs/api/stats.html @@ -126,20 +126,20 @@

Statistics

-
-GET /api/stats/(int: user_id)/by_sport
+
+GET /api/stats/(user_name)/by_sport

Get activities statistics for a user by sport

Example requests:

  • without parameters (get stats for all sports with activities)

-
GET /api/stats/1/by_sport HTTP/1.1
+
GET /api/stats/admin/by_sport HTTP/1.1
 
  • with sport id

-
GET /api/stats/1/by_sport?sport_id=1 HTTP/1.1
+
GET /api/stats/admin/by_sport?sport_id=1 HTTP/1.1
 

Example responses:

@@ -191,7 +191,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • user_id (integer) – user id

  • +
  • user_name (integer) – user name

Query Parameters
@@ -224,20 +224,20 @@
-
-GET /api/stats/(int: user_id)/by_time
+
+GET /api/stats/(user_name)/by_time

Get activities statistics for a user by time

Example requests:

  • without parameters

-
GET /api/stats/1/by_time HTTP/1.1
+
GET /api/stats/admin/by_time HTTP/1.1
 
  • with parameters

-
GET /api/stats/1/by_time?from=2018-01-01&to=2018-06-30&time=week HTTP/1.1
+
GET /api/stats/admin/by_time?from=2018-01-01&to=2018-06-30&time=week HTTP/1.1  # noqa
 

Example responses:

@@ -293,7 +293,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • user_id (integer) – user id

  • +
  • user_name (integer) – user name

Query Parameters
diff --git a/docs/http-routingtable.html b/docs/http-routingtable.html index ea792a56..6b2c0ef0 100644 --- a/docs/http-routingtable.html +++ b/docs/http-routingtable.html @@ -197,12 +197,12 @@ - GET /api/stats/(int:user_id)/by_sport + GET /api/stats/(user_name)/by_sport - GET /api/stats/(int:user_id)/by_time + GET /api/stats/(user_name)/by_time diff --git a/docs/objects.inv b/docs/objects.inv index 91a9a699..2d461bc7 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/searchindex.js b/docs/searchindex.js index 6d28629d..2b62fb64 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/activities","api/auth","api/configuration","api/index","api/records","api/sports","api/stats","api/users","changelog","features","index","installation","troubleshooting/administrator","troubleshooting/index","troubleshooting/user"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["api/activities.rst","api/auth.rst","api/configuration.rst","api/index.rst","api/records.rst","api/sports.rst","api/stats.rst","api/users.rst","changelog.md","features.rst","index.rst","installation.rst","troubleshooting/administrator.rst","troubleshooting/index.rst","troubleshooting/user.rst"],objects:{"":{"/api/activities":[0,1,1,"post--api-activities"],"/api/activities/(int:activity_id)":[0,3,1,"patch--api-activities-(int-activity_id)"],"/api/activities/(int:activity_id)/chart_data":[0,0,1,"get--api-activities-(int-activity_id)-chart_data"],"/api/activities/(int:activity_id)/chart_data/segment/(int:segment_id)":[0,0,1,"get--api-activities-(int-activity_id)-chart_data-segment-(int-segment_id)"],"/api/activities/(int:activity_id)/gpx":[0,0,1,"get--api-activities-(int-activity_id)-gpx"],"/api/activities/(int:activity_id)/gpx/segment/(int:segment_id)":[0,0,1,"get--api-activities-(int-activity_id)-gpx-segment-(int-segment_id)"],"/api/activities/map/(map_id)":[0,0,1,"get--api-activities-map-(map_id)"],"/api/activities/no_gpx":[0,1,1,"post--api-activities-no_gpx"],"/api/auth/login":[1,1,1,"post--api-auth-login"],"/api/auth/logout":[1,0,1,"get--api-auth-logout"],"/api/auth/picture":[1,1,1,"post--api-auth-picture"],"/api/auth/profile":[1,0,1,"get--api-auth-profile"],"/api/auth/profile/edit":[1,1,1,"post--api-auth-profile-edit"],"/api/auth/register":[1,1,1,"post--api-auth-register"],"/api/config":[2,3,1,"patch--api-config"],"/api/ping":[7,0,1,"get--api-ping"],"/api/records":[4,0,1,"get--api-records"],"/api/sports":[5,0,1,"get--api-sports"],"/api/sports/(int:sport_id)":[5,3,1,"patch--api-sports-(int-sport_id)"],"/api/stats/(int:user_id)/by_sport":[6,0,1,"get--api-stats-(int-user_id)-by_sport"],"/api/stats/(int:user_id)/by_time":[6,0,1,"get--api-stats-(int-user_id)-by_time"],"/api/stats/all":[6,0,1,"get--api-stats-all"],"/api/users":[7,0,1,"get--api-users"],"/api/users/(user_name)":[7,0,1,"get--api-users-(user_name)"],"/api/users/(user_name)/picture":[7,0,1,"get--api-users-(user_name)-picture"]}},objnames:{"0":["http","get","HTTP get"],"1":["http","post","HTTP post"],"2":["http","delete","HTTP delete"],"3":["http","patch","HTTP patch"]},objtypes:{"0":"http:get","1":"http:post","2":"http:delete","3":"http:patch"},terms:{"0mb":[0,1],"10mb":11,"1mb":11,"2e1ee2c":8,"34614d5":8,"4c3fc34":8,"boolean":2,"default":[0,6,11],"export":10,"float":0,"int":[0,5,6],"null":[0,1,7],"return":[0,4],"static":11,"true":[1,2,5,7,11],"try":[0,1],For:11,NOT:[0,1,5],Not:[0,1,5,6,7],That:1,The:[8,9,11],Use:8,accord:10,account:[8,9],acit:0,activ:[3,5,6,8,10],activity_d:[0,4],activity_id:[0,4],adapt:11,add:[8,9,10],admin:[1,2,5,7,8,9,11],administr:[0,1,8,9,10,13],again:[0,1,2,4,5,6,7],all:[4,5,6,7,11],allow:[0,1,2,10,11],alpinequest:10,alreadi:1,also:10,android:10,anymor:8,api:[0,1,2,4,5,6,7,8,9,10,11,12],app:[10,11],applic:[0,1,2,4,5,6,7,10,11],arch:11,archiv:[2,11],archlinux:11,ascent:0,auth:[0,1,2,4,5,6,7],auth_token:1,auth_user_id:[0,2,4,5,6,7],authent:[0,2,3,4,5,6,7,10],author:[0,1,2,4,5,6,7],avail:[4,9,10],ave_spe:0,ave_speed_from:0,ave_speed_to:0,averag:[0,4,8,9],b862a77:8,background:8,backup:11,bad:[0,1,2,5],bearer:[0,1,2,4,5,6,7],befor:11,beta:11,bike:[0,5,8,9],bio:[1,7],biographi:1,birth:1,birth_dat:[1,7],bound:0,build:11,by_sport:6,by_tim:6,calcul:8,calendar:[8,9],can:[8,9,10,11],cannot:8,chang:[9,10,11],charact:[1,13],chart:[0,8,9,11],chart_data:0,check:[7,12],choos:8,client:[8,11,12],clone:11,code:[0,1,2,4,5,6,7],color:8,column:13,com:[1,7,11],config:[2,11,12],configur:[3,10],confirm:1,contact:[0,1],contain:8,content:[0,1,2,4,5,6,7],coordin:11,copi:11,correctli:[8,12],creat:[0,1,8,9],created_at:[1,7],creation:[8,9],creation_d:0,credenti:1,current:8,custom:[11,12],cycl:[5,8,9],dai:8,dark:11,darkski:[8,9,11],dashboard:[8,10],data:[0,1,2,4,5,6,7,8,10,11,13],databas:11,date:[0,1,6,8,9],debian:11,defaut:11,defin:11,definit:8,delet:[0,1,8,9],depend:8,desc:0,descent:0,describ:11,descript:11,detail:[7,8,10],develop:10,differ:8,directori:11,disabl:[1,8,9],displai:[0,8,9,10,11],distanc:[0,4,8,9],distance_from:0,distance_to:0,document:[8,10,11],doe:[0,1,6,7,8],don:1,down:8,download:11,drop:8,durat:[0,4,8,9],duration_from:0,duration_to:0,dure:[0,1],edit:[1,8,9],elev:[0,8,9,11],email:[1,7,11],empti:8,enabl:2,encount:11,end:[0,6],endpoint:[3,7,13],english:9,enter:[8,9],entiti:[0,1],environ:10,environn:12,error:[0,1,2,5,8],europ:[1,7],even:[8,9],exampl:[0,1,2,4,5,6,7,10,11,12],exce:[0,1],exist:[0,1,6,7,10,12],exodu:10,expir:[0,1,2,4,5,6,7],extens:[0,1],fa33f4d996844a5c73ecd1ae24456ab8:0,fals:[0,1,2,5,7],farest:[4,8,9],featur:10,fetch:11,file:[0,1,2,8,9,10,11,12],filter:[8,9],first:[1,10],first_nam:[1,7],fittracke:[9,11],fittrackee_api:11,fix:10,flask:11,flaticon:11,follow:[4,11],forbidden:[0,1,2,5,6],forecast:11,form:[0,1],format:[0,1,6],former:11,forrunn:10,found:[0,1,5,6,7],frame:6,freepik:11,french:[9,10],fri:0,from:[0,2,4,5,6,7,10,11],gener:11,get:[0,1,2,4,5,6,7],gif:1,git:11,github:11,gmt:[0,1,4,7],gpl:10,gpx:[0,8,9,10,11],gpx_limit_import:2,gpxpy:11,has_act:5,have:[0,2,5,6,8],header:[0,1,2,4,5,6,7],health:7,hike:[5,8,9],his:[8,9],http:[0,1,2,4,5,6,7,11,12],i18n:8,icon:11,imag:[0,1,7,11],img:5,improv:10,incorrect:8,info:1,inform:[8,10],initi:[11,12],instal:10,instanc:[2,11],integ:[0,2,4,5,6,7],integr:2,interceptor:8,intern:[0,1,2,5],invalid:[0,1,2,4,5,6,7],is_act:5,is_registration_en:2,issu:[10,11],jan:0,javascript:11,jpeg:7,jpg:1,json:[0,1,2,4,5,6,7,13],jul:[0,1,4,7],keep:10,kei:[8,9,11],label:5,languag:[1,7],larg:[0,1],last:[1,11],last_nam:[1,7],latitud:0,leaflet:[0,11],least:0,limit:8,line:13,linux:11,list:[8,10],load:8,local:[8,10],localhost:[11,12],locat:[1,7],log:[0,1,2,4,5,6,7,10,11],login:[1,11],logout:[1,8],longest:[4,8,9],longitud:0,made:[11,12],mai:11,make:11,makefil:[11,12],manag:8,mandatori:[0,11],map:[0,8,9,10,11],map_id:0,match:1,max:[0,2,11],max_alt:0,max_single_file_s:2,max_spe:0,max_speed_from:0,max_speed_to:0,max_us:2,max_zip_file_s:2,maxim:0,maximum:[4,8,9],mean:12,messag:[0,1,7],min_alt:0,minim:0,minor:10,mobil:10,modification_d:0,mon:0,mondai:[1,6,9],montain:[8,9],month:[6,8,9],more:[8,10],morn:0,mountain:5,mous:8,move:[0,8],mpwoadmin:11,multipart:[0,1],must:[1,2,5,8,9,11],name:[1,7],nb_activ:[1,6,7],nb_sport:[1,7],necessari:11,need:11,network:12,next_act:0,no_gpx:0,non:5,note:[0,8,9,11],now:[8,9,11],number:[0,2,11],oauth:[0,1,2,4,5,6,7],object:[0,1,2,5],one:0,onli:[0,8,9],open:[10,11],option:11,order:0,other:11,out:1,outdoor:10,over:8,own:10,owner:[8,9],packag:[8,11],page:0,pagin:0,paramet:[0,1,2,4,5,6,7],pari:[1,7],pars:[11,13],part:[0,1],password:[1,11],password_conf:1,past:11,patch:[0,2,5],paus:[0,8],payload:[0,1,2,5],per:0,per_pag:0,permiss:[0,2,5,6],pg_dump:11,pictur:[0,1,7,11],ping:7,pipenv:8,pleas:[0,1,2,4,5,6,7],png:[0,1,5],poetri:[8,11],point:8,pong:7,possibl:10,post:[0,1],postgresql:11,prefer:1,prerequisit:10,previous_act:0,privai:10,product:[10,11],profil:1,project:11,proprietari:10,provid:[0,1,2,4,5,6,7,8,9],pull:11,python:[8,11],queri:[0,6],react:11,react_app_allow_registr:11,react_app_api_url:12,react_app_gpx_limit_import:11,react_app_max_single_file_s:11,react_app_max_zip_file_s:11,react_app_thunderforest_api_kei:11,readi:[10,11],rebuild:12,rechart:[0,11],record:[0,3,8,9,10],record_typ:[0,4],redux:11,regist:[1,2,11],registr:[1,2,8,9],relat:11,releas:[10,11],replac:8,repo:11,report:10,repositori:11,request:[0,1,2,4,5,6,7,12],requir:1,respons:[0,1,2,4,5,6,7],restart:11,rout:8,run:[5,8,9,11],runner:10,sam:[1,7],same:8,samr1:11,sat:7,save:9,search:8,second:0,see:[8,9,10,11,12],segment:[0,8,9],segment_id:0,select:[0,1],serv:11,server:[0,1,2,5,10,11],set:[9,11],sever:10,show:8,side:8,signatur:[0,1,2,4,5,6,7],simplifi:8,sinc:11,singl:[2,7],size:[0,1,2,8,11],sky:11,some:[0,8,11],sorri:1,sort:0,speed:[0,4,8,9,11],spinner:8,sport:[0,3,6,8,9,10,11],sport_id:[0,4,5,6],sports_list:[1,7],standard:[8,9],start:[0,1,6,9,11],stat:[6,8],staticmap:11,statist:[3,10],statu:[0,1,2,4,5,6,7],step:11,still:10,stop:11,store:10,street:10,string:[0,1,5,6],success:[0,1,2,4,5,6,7],successfulli:1,sun:[0,1,4,7],sundai:[0,6,9],support:[8,9],system:11,tab:12,tar:11,test:11,than:8,them:10,thi:[0,8,10,11],thunderforest:11,time:[0,1,6,8,9],timezon:[1,7,8],titl:0,todo:[11,14],token:[0,1,2,4,5,6,7],too:[0,1],tooltip:8,total:8,total_dist:[1,6,7],total_dur:[1,6,7],track:10,tracker:10,transport:[5,8,9],troubleshoot:10,type:[0,1,2,4,5,6,7],unauthor:[0,1,2,4,5,6,7],undefin:12,under:10,unexpect:13,updat:[0,1,2,5,8,11],upgrad:10,upload:[8,9,11],url:8,user:[0,1,2,3,4,5,6,8,10,11,13],user_id:[0,4,6],user_nam:7,usernam:[1,7],usernanm:1,using:[0,10],valid:[0,1,2,4,5,6,7],valu:[0,4,11],variabl:[10,12],version:[10,11],view:8,virtualenv:11,walk:[5,8,9],weather:[8,9,11],weather_api:11,weather_end:0,weather_start:0,web:[0,1,2,4,5,6,7,10],week:[1,6,8,9],weekend:8,weekm:[1,6],were:8,wget:11,when:8,which:9,wiki:8,with_gpx:0,without:[0,6,8,9,10],workout:10,written:11,www:11,xzf:11,yaourt:11,yarn:11,year:6,yet:[10,11],you:[0,2,5,6,10],your:10,zip:[0,2,11],zone:1},titles:["Activities","Authentication","Configuration","API documentation","Records","Sports","Statistics","Users","Change log","Features","FitTrackee","Installation","Administrator","Troubleshooting","User"],titleterms:{"new":8,activ:[0,9],administr:12,api:3,authent:1,avail:8,bug:8,chang:8,charact:12,close:8,column:12,configur:2,content:10,dashboard:9,data:12,detail:9,dev:11,document:3,environ:11,featur:[8,9],first:8,fittracke:[8,10],fix:8,french:8,improv:8,instal:11,issu:8,json:12,line:12,list:9,log:8,minor:8,misc:8,pars:12,prerequisit:11,prod:11,record:4,releas:8,sport:5,statist:[6,8,9],tabl:10,translat:9,troubleshoot:13,unexpect:12,upgrad:11,user:[7,9,14],variabl:11,version:8,workout:9}}) \ No newline at end of file +Search.setIndex({docnames:["api/activities","api/auth","api/configuration","api/index","api/records","api/sports","api/stats","api/users","changelog","features","index","installation","troubleshooting/administrator","troubleshooting/index","troubleshooting/user"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["api/activities.rst","api/auth.rst","api/configuration.rst","api/index.rst","api/records.rst","api/sports.rst","api/stats.rst","api/users.rst","changelog.md","features.rst","index.rst","installation.rst","troubleshooting/administrator.rst","troubleshooting/index.rst","troubleshooting/user.rst"],objects:{"":{"/api/activities":[0,1,1,"post--api-activities"],"/api/activities/(int:activity_id)":[0,3,1,"patch--api-activities-(int-activity_id)"],"/api/activities/(int:activity_id)/chart_data":[0,0,1,"get--api-activities-(int-activity_id)-chart_data"],"/api/activities/(int:activity_id)/chart_data/segment/(int:segment_id)":[0,0,1,"get--api-activities-(int-activity_id)-chart_data-segment-(int-segment_id)"],"/api/activities/(int:activity_id)/gpx":[0,0,1,"get--api-activities-(int-activity_id)-gpx"],"/api/activities/(int:activity_id)/gpx/segment/(int:segment_id)":[0,0,1,"get--api-activities-(int-activity_id)-gpx-segment-(int-segment_id)"],"/api/activities/map/(map_id)":[0,0,1,"get--api-activities-map-(map_id)"],"/api/activities/no_gpx":[0,1,1,"post--api-activities-no_gpx"],"/api/auth/login":[1,1,1,"post--api-auth-login"],"/api/auth/logout":[1,0,1,"get--api-auth-logout"],"/api/auth/picture":[1,1,1,"post--api-auth-picture"],"/api/auth/profile":[1,0,1,"get--api-auth-profile"],"/api/auth/profile/edit":[1,1,1,"post--api-auth-profile-edit"],"/api/auth/register":[1,1,1,"post--api-auth-register"],"/api/config":[2,3,1,"patch--api-config"],"/api/ping":[7,0,1,"get--api-ping"],"/api/records":[4,0,1,"get--api-records"],"/api/sports":[5,0,1,"get--api-sports"],"/api/sports/(int:sport_id)":[5,3,1,"patch--api-sports-(int-sport_id)"],"/api/stats/(user_name)/by_sport":[6,0,1,"get--api-stats-(user_name)-by_sport"],"/api/stats/(user_name)/by_time":[6,0,1,"get--api-stats-(user_name)-by_time"],"/api/stats/all":[6,0,1,"get--api-stats-all"],"/api/users":[7,0,1,"get--api-users"],"/api/users/(user_name)":[7,0,1,"get--api-users-(user_name)"],"/api/users/(user_name)/picture":[7,0,1,"get--api-users-(user_name)-picture"]}},objnames:{"0":["http","get","HTTP get"],"1":["http","post","HTTP post"],"2":["http","delete","HTTP delete"],"3":["http","patch","HTTP patch"]},objtypes:{"0":"http:get","1":"http:post","2":"http:delete","3":"http:patch"},terms:{"0mb":[0,1],"10mb":11,"1mb":11,"2e1ee2c":8,"34614d5":8,"4c3fc34":8,"boolean":2,"default":[0,6,11],"export":10,"float":0,"int":[0,5],"null":[0,1,7],"return":[0,4],"static":11,"true":[1,2,5,7,11],"try":[0,1],For:11,NOT:[0,1,5],Not:[0,1,5,6,7],That:1,The:[8,9,11],Use:8,accord:10,account:[8,9],acit:0,activ:[3,5,6,8,10],activity_d:[0,4],activity_id:[0,4],adapt:11,add:[8,9,10],admin:[0,1,2,4,5,6,7,8,9,11],administr:[0,1,8,9,10,13],again:[0,1,2,4,5,6,7],all:[4,5,6,7,11],allow:[0,1,2,10,11],alpinequest:10,alreadi:1,also:10,android:10,anymor:8,api:[0,1,2,4,5,6,7,8,9,10,11,12],app:[10,11],applic:[0,1,2,4,5,6,7,10,11],arch:11,archiv:[2,11],archlinux:11,ascent:0,auth:[0,1,2,4,5,6,7],auth_token:1,auth_user_id:[0,2,4,5,6,7],authent:[0,2,3,4,5,6,7,10],author:[0,1,2,4,5,6,7],avail:[4,9,10],ave_spe:0,ave_speed_from:0,ave_speed_to:0,averag:[0,4,8,9],b862a77:8,background:8,backup:11,bad:[0,1,2,5],bearer:[0,1,2,4,5,6,7],befor:11,beta:11,bike:[0,5,8,9],bio:[1,7],biographi:1,birth:1,birth_dat:[1,7],bound:0,build:11,by_sport:6,by_tim:6,calcul:8,calendar:[8,9],can:[8,9,10,11],cannot:8,chang:[9,10,11],charact:[1,13],chart:[0,8,9,11],chart_data:0,check:[7,12],choos:8,client:[8,11,12],clone:11,code:[0,1,2,4,5,6,7],color:8,column:13,com:[1,7,11],config:[2,11,12],configur:[3,10],confirm:1,contact:[0,1],contain:8,content:[0,1,2,4,5,6,7],coordin:11,copi:11,correctli:[8,12],creat:[0,1,8,9],created_at:[1,7],creation:[8,9],creation_d:0,credenti:1,current:8,custom:[11,12],cycl:[5,8,9],dai:8,dark:11,darkski:[8,9,11],dashboard:[8,10],data:[0,1,2,4,5,6,7,8,10,11,13],databas:11,date:[0,1,6,8,9],debian:11,defaut:11,defin:11,definit:8,delet:[0,1,8,9],depend:8,desc:0,descent:0,describ:11,descript:11,detail:[7,8,10],develop:10,differ:8,directori:11,disabl:[1,8,9],displai:[0,8,9,10,11],distanc:[0,4,8,9],distance_from:0,distance_to:0,document:[8,10,11],doe:[0,1,6,7,8],don:1,down:8,download:11,drop:8,durat:[0,4,8,9],duration_from:0,duration_to:0,dure:[0,1],edit:[1,8,9],elev:[0,8,9,11],email:[1,7,11],empti:8,enabl:2,encount:11,end:[0,6],endpoint:[3,7,13],english:9,enter:[8,9],entiti:[0,1],environ:10,environn:12,error:[0,1,2,5,8],europ:[1,7],even:[8,9],exampl:[0,1,2,4,5,6,7,10,11,12],exce:[0,1],exist:[0,1,6,7,10,12],exodu:10,expir:[0,1,2,4,5,6,7],extens:[0,1],fa33f4d996844a5c73ecd1ae24456ab8:0,fals:[0,1,2,5,7],farest:[4,8,9],featur:10,fetch:11,file:[0,1,2,8,9,10,11,12],filter:[8,9],first:[1,10],first_nam:[1,7],fittracke:[9,11],fittrackee_api:11,fix:10,flask:11,flaticon:11,follow:[4,11],forbidden:[0,1,2,5,6],forecast:11,form:[0,1],format:[0,1,6],former:11,forrunn:10,found:[0,1,5,6,7],frame:6,freepik:11,french:[9,10],fri:0,from:[0,2,4,5,6,7,10,11],gener:11,get:[0,1,2,4,5,6,7],gif:1,git:11,github:11,gmt:[0,1,4,7],gpl:10,gpx:[0,8,9,10,11],gpx_limit_import:2,gpxpy:11,has_act:5,have:[0,2,5,6,8],header:[0,1,2,4,5,6,7],health:7,hike:[5,8,9],his:[8,9],http:[0,1,2,4,5,6,7,11,12],i18n:8,icon:11,imag:[0,1,7,11],img:5,improv:10,incorrect:8,info:1,inform:[8,10],initi:[11,12],instal:10,instanc:[2,11],integ:[0,2,4,5,6,7],integr:2,interceptor:8,intern:[0,1,2,5],invalid:[0,1,2,4,5,6,7],is_act:5,is_registration_en:2,issu:[10,11],jan:0,javascript:11,jpeg:7,jpg:1,json:[0,1,2,4,5,6,7,13],jul:[0,1,4,7],keep:10,kei:[8,9,11],label:5,languag:[1,7],larg:[0,1],last:[1,11],last_nam:[1,7],latitud:0,leaflet:[0,11],least:0,limit:8,line:13,linux:11,list:[8,10],load:8,local:[8,10],localhost:[11,12],locat:[1,7],log:[0,1,2,4,5,6,7,10,11],login:[1,11],logout:[1,8],longest:[4,8,9],longitud:0,made:[11,12],mai:11,make:11,makefil:[11,12],manag:8,mandatori:[0,11],map:[0,8,9,10,11],map_id:0,match:1,max:[0,2,11],max_alt:0,max_single_file_s:2,max_spe:0,max_speed_from:0,max_speed_to:0,max_us:2,max_zip_file_s:2,maxim:0,maximum:[4,8,9],mean:12,messag:[0,1,7],min_alt:0,minim:0,minor:10,mobil:10,modification_d:0,mon:0,mondai:[1,6,9],montain:[8,9],month:[6,8,9],more:[8,10],morn:0,mountain:5,mous:8,move:[0,8],mpwoadmin:11,multipart:[0,1],must:[1,2,5,8,9,11],name:[1,6,7],nb_activ:[1,6,7],nb_sport:[1,7],necessari:11,need:11,network:12,next_act:0,no_gpx:0,non:5,noqa:6,note:[0,8,9,11],now:[8,9,11],number:[0,2,11],oauth:[0,1,2,4,5,6,7],object:[0,1,2,5],one:0,onli:[0,8,9],open:[10,11],option:11,order:0,other:11,out:1,outdoor:10,over:8,own:10,owner:[8,9],packag:[8,11],page:0,pagin:0,paramet:[0,1,2,4,5,6,7],pari:[1,7],pars:[11,13],part:[0,1],password:[1,11],password_conf:1,past:11,patch:[0,2,5],paus:[0,8],payload:[0,1,2,5],per:0,per_pag:0,permiss:[0,2,5,6],pg_dump:11,pictur:[0,1,7,11],ping:7,pipenv:8,pleas:[0,1,2,4,5,6,7],png:[0,1,5],poetri:[8,11],point:8,pong:7,possibl:10,post:[0,1],postgresql:11,prefer:1,prerequisit:10,previous_act:0,privai:10,product:[10,11],profil:1,project:11,proprietari:10,provid:[0,1,2,4,5,6,7,8,9],pull:11,python:[8,11],queri:[0,6],react:11,react_app_allow_registr:11,react_app_api_url:12,react_app_gpx_limit_import:11,react_app_max_single_file_s:11,react_app_max_zip_file_s:11,react_app_thunderforest_api_kei:11,readi:[10,11],rebuild:12,rechart:[0,11],record:[0,3,8,9,10],record_typ:[0,4],redux:11,regist:[1,2,11],registr:[1,2,8,9],relat:11,releas:[10,11],replac:8,repo:11,report:10,repositori:11,request:[0,1,2,4,5,6,7,12],requir:1,respons:[0,1,2,4,5,6,7],restart:11,rout:8,run:[5,8,9,11],runner:10,sam:[1,7],same:8,samr1:11,sat:7,save:9,search:8,second:0,see:[8,9,10,11,12],segment:[0,8,9],segment_id:0,select:[0,1],serv:11,server:[0,1,2,5,10,11],set:[9,11],sever:10,show:8,side:8,signatur:[0,1,2,4,5,6,7],simplifi:8,sinc:11,singl:[2,7],size:[0,1,2,8,11],sky:11,some:[0,8,11],sorri:1,sort:0,speed:[0,4,8,9,11],spinner:8,sport:[0,3,6,8,9,10,11],sport_id:[0,4,5,6],sports_list:[1,7],standard:[8,9],start:[0,1,6,9,11],stat:[6,8],staticmap:11,statist:[3,10],statu:[0,1,2,4,5,6,7],step:11,still:10,stop:11,store:10,street:10,string:[0,1,5,6],success:[0,1,2,4,5,6,7],successfulli:1,sun:[0,1,4,7],sundai:[0,6,9],support:[8,9],system:11,tab:12,tar:11,test:11,than:8,them:10,thi:[0,8,10,11],thunderforest:11,time:[0,1,6,8,9],timezon:[1,7,8],titl:0,todo:[11,14],token:[0,1,2,4,5,6,7],too:[0,1],tooltip:8,total:8,total_dist:[1,6,7],total_dur:[1,6,7],track:10,tracker:10,transport:[5,8,9],troubleshoot:10,type:[0,1,2,4,5,6,7],unauthor:[0,1,2,4,5,6,7],undefin:12,under:10,unexpect:13,updat:[0,1,2,5,8,11],upgrad:10,upload:[8,9,11],url:8,user:[0,1,2,3,4,5,6,8,10,11,13],user_nam:[6,7],usernam:[1,7],usernanm:1,using:[0,10],valid:[0,1,2,4,5,6,7],valu:[0,4,11],variabl:[10,12],version:[10,11],view:8,virtualenv:11,walk:[5,8,9],weather:[8,9,11],weather_api:11,weather_end:0,weather_start:0,web:[0,1,2,4,5,6,7,10],week:[1,6,8,9],weekend:8,weekm:[1,6],were:8,wget:11,when:8,which:9,wiki:8,with_gpx:0,without:[0,6,8,9,10],workout:10,written:11,www:11,xzf:11,yaourt:11,yarn:11,year:6,yet:[10,11],you:[0,2,5,6,10],your:10,zip:[0,2,11],zone:1},titles:["Activities","Authentication","Configuration","API documentation","Records","Sports","Statistics","Users","Change log","Features","FitTrackee","Installation","Administrator","Troubleshooting","User"],titleterms:{"new":8,activ:[0,9],administr:12,api:3,authent:1,avail:8,bug:8,chang:8,charact:12,close:8,column:12,configur:2,content:10,dashboard:9,data:12,detail:9,dev:11,document:3,environ:11,featur:[8,9],first:8,fittracke:[8,10],fix:8,french:8,improv:8,instal:11,issu:8,json:12,line:12,list:9,log:8,minor:8,misc:8,pars:12,prerequisit:11,prod:11,record:4,releas:8,sport:5,statist:[6,8,9],tabl:10,translat:9,troubleshoot:13,unexpect:12,upgrad:11,user:[7,9,14],variabl:11,version:8,workout:9}}) \ No newline at end of file diff --git a/fittrackee_api/fittrackee_api/activities/activities.py b/fittrackee_api/fittrackee_api/activities/activities.py index 8079238a..433c2939 100644 --- a/fittrackee_api/fittrackee_api/activities/activities.py +++ b/fittrackee_api/fittrackee_api/activities/activities.py @@ -91,7 +91,7 @@ def get_activities(auth_user_id): "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -100,7 +100,7 @@ def get_activities(auth_user_id): "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -109,7 +109,7 @@ def get_activities(auth_user_id): "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -118,14 +118,14 @@ def get_activities(auth_user_id): "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -307,7 +307,7 @@ def get_activity(auth_user_id, activity_id): "segments": [], "sport_id": 1, "title": "biking on sunday morning", - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -757,7 +757,7 @@ def post_activity(auth_user_id): "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -766,7 +766,7 @@ def post_activity(auth_user_id): "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -775,7 +775,7 @@ def post_activity(auth_user_id): "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -784,14 +784,14 @@ def post_activity(auth_user_id): "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -922,7 +922,7 @@ def post_activity_no_gpx(auth_user_id): "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -931,7 +931,7 @@ def post_activity_no_gpx(auth_user_id): "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -940,7 +940,7 @@ def post_activity_no_gpx(auth_user_id): "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -949,14 +949,14 @@ def post_activity_no_gpx(auth_user_id): "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false @@ -1069,7 +1069,7 @@ def update_activity(auth_user_id, activity_id): "id": 4, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -1078,7 +1078,7 @@ def update_activity(auth_user_id, activity_id): "id": 3, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "0:17:04" }, { @@ -1087,7 +1087,7 @@ def update_activity(auth_user_id, activity_id): "id": 2, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 }, { @@ -1096,14 +1096,14 @@ def update_activity(auth_user_id, activity_id): "id": 1, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 10.0 } ], "segments": [], "sport_id": 1, "title": null, - "user_id": 1, + "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false diff --git a/fittrackee_api/fittrackee_api/activities/models.py b/fittrackee_api/fittrackee_api/activities/models.py index 5fcf62ab..57fe60fe 100644 --- a/fittrackee_api/fittrackee_api/activities/models.py +++ b/fittrackee_api/fittrackee_api/activities/models.py @@ -227,7 +227,7 @@ class Activity(db.Model): ) return { "id": self.id, - "user_id": self.user_id, + "user": self.user.username, "sport_id": self.sport_id, "title": self.title, "creation_date": self.creation_date, @@ -424,7 +424,7 @@ class Record(db.Model): return { "id": self.id, - "user_id": self.user_id, + "user": self.user.username, "sport_id": self.sport_id, "activity_id": self.activity_id, "record_type": self.record_type, diff --git a/fittrackee_api/fittrackee_api/activities/records.py b/fittrackee_api/fittrackee_api/activities/records.py index 17aa1f49..a2daa572 100644 --- a/fittrackee_api/fittrackee_api/activities/records.py +++ b/fittrackee_api/fittrackee_api/activities/records.py @@ -43,7 +43,7 @@ def get_records(auth_user_id): "id": 9, "record_type": "AS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 }, { @@ -52,7 +52,7 @@ def get_records(auth_user_id): "id": 10, "record_type": "FD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 }, { @@ -61,7 +61,7 @@ def get_records(auth_user_id): "id": 11, "record_type": "LD", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": "1:01:00" }, { @@ -70,7 +70,7 @@ def get_records(auth_user_id): "id": 12, "record_type": "MS", "sport_id": 1, - "user_id": 1, + "user": "admin", "value": 18 } ] diff --git a/fittrackee_api/fittrackee_api/activities/stats.py b/fittrackee_api/fittrackee_api/activities/stats.py index fb1b7826..a5dc06bc 100644 --- a/fittrackee_api/fittrackee_api/activities/stats.py +++ b/fittrackee_api/fittrackee_api/activities/stats.py @@ -13,9 +13,9 @@ from .utils_format import convert_timedelta_to_integer stats_blueprint = Blueprint('stats', __name__) -def get_activities(user_id, filter_type): +def get_activities(user_name, filter_type): try: - user = User.query.filter_by(id=user_id).first() + user = User.query.filter_by(username=user_name).first() if not user: response_object = { 'status': 'not found', @@ -50,7 +50,7 @@ def get_activities(user_id, filter_type): activities = ( Activity.query.filter( - Activity.user_id == user_id, + Activity.user_id == user.id, Activity.activity_date >= date_from if date_from else True, Activity.activity_date < date_to + timedelta(seconds=1) if date_to @@ -97,11 +97,11 @@ def get_activities(user_id, filter_type): elif time == 'month': time_period = datetime.strftime( activity.activity_date, "%Y-%m" - ) # noqa + ) elif time == 'year' or not time: time_period = datetime.strftime( activity.activity_date, "%Y" - ) # noqa + ) else: response_object = { 'status': 'fail', @@ -140,9 +140,9 @@ def get_activities(user_id, filter_type): return jsonify(response_object), code -@stats_blueprint.route('/stats//by_time', methods=['GET']) +@stats_blueprint.route('/stats//by_time', methods=['GET']) @authenticate -def get_activities_by_time(auth_user_id, user_id): +def get_activities_by_time(auth_user_id, user_name): """ Get activities statistics for a user by time @@ -152,13 +152,13 @@ def get_activities_by_time(auth_user_id, user_id): .. sourcecode:: http - GET /api/stats/1/by_time HTTP/1.1 + GET /api/stats/admin/by_time HTTP/1.1 - with parameters .. sourcecode:: http - GET /api/stats/1/by_time?from=2018-01-01&to=2018-06-30&time=week HTTP/1.1 + GET /api/stats/admin/by_time?from=2018-01-01&to=2018-06-30&time=week HTTP/1.1 # noqa **Example responses**: @@ -211,7 +211,7 @@ def get_activities_by_time(auth_user_id, user_id): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer user_id: user id + :param integer user_name: user name :query string from: start date (format: ``%Y-%m-%d``) :query string to: end date (format: ``%Y-%m-%d``) @@ -233,12 +233,12 @@ def get_activities_by_time(auth_user_id, user_id): - User does not exist. """ - return get_activities(user_id, 'by_time') + return get_activities(user_name, 'by_time') -@stats_blueprint.route('/stats//by_sport', methods=['GET']) +@stats_blueprint.route('/stats//by_sport', methods=['GET']) @authenticate -def get_activities_by_sport(auth_user_id, user_id): +def get_activities_by_sport(auth_user_id, user_name): """ Get activities statistics for a user by sport @@ -248,13 +248,13 @@ def get_activities_by_sport(auth_user_id, user_id): .. sourcecode:: http - GET /api/stats/1/by_sport HTTP/1.1 + GET /api/stats/admin/by_sport HTTP/1.1 - with sport id .. sourcecode:: http - GET /api/stats/1/by_sport?sport_id=1 HTTP/1.1 + GET /api/stats/admin/by_sport?sport_id=1 HTTP/1.1 **Example responses**: @@ -303,7 +303,7 @@ def get_activities_by_sport(auth_user_id, user_id): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer user_id: user id + :param integer user_name: user name :query integer sport_id: sport id @@ -319,7 +319,7 @@ def get_activities_by_sport(auth_user_id, user_id): - Sport does not exist. """ - return get_activities(user_id, 'by_sport') + return get_activities(user_name, 'by_sport') @stats_blueprint.route('/stats/all', methods=['GET']) diff --git a/fittrackee_api/fittrackee_api/tests/test_activities_api_0_get.py b/fittrackee_api/fittrackee_api/tests/test_activities_api_0_get.py index a1d5c646..019afb0d 100644 --- a/fittrackee_api/fittrackee_api/tests/test_activities_api_0_get.py +++ b/fittrackee_api/fittrackee_api/tests/test_activities_api_0_get.py @@ -35,8 +35,8 @@ def test_get_all_activities_for_authenticated_user( assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa - assert 1 == data['data']['activities'][0]['user_id'] + ) + assert 'test' == data['data']['activities'][0]['user'] assert 2 == data['data']['activities'][0]['sport_id'] assert 12.0 == data['data']['activities'][0]['distance'] assert '1:40:00' == data['data']['activities'][0]['duration'] @@ -45,8 +45,8 @@ def test_get_all_activities_for_authenticated_user( assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa - assert 1 == data['data']['activities'][1]['user_id'] + ) + assert 'test' == data['data']['activities'][1]['user'] assert 1 == data['data']['activities'][1]['sport_id'] assert 10.0 == data['data']['activities'][1]['distance'] assert '0:17:04' == data['data']['activities'][1]['duration'] @@ -116,13 +116,13 @@ def test_get_activities_pagination( assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert '0:50:00' == data['data']['activities'][0]['duration'] assert 'creation_date' in data['data']['activities'][4] assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][4]['activity_date'] - ) # noqa + ) assert '0:17:04' == data['data']['activities'][4]['duration'] response = client.get( @@ -141,13 +141,13 @@ def test_get_activities_pagination( assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert '0:50:00' == data['data']['activities'][0]['duration'] assert 'creation_date' in data['data']['activities'][4] assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][4]['activity_date'] - ) # noqa + ) assert '0:17:04' == data['data']['activities'][4]['duration'] response = client.get( @@ -166,13 +166,13 @@ def test_get_activities_pagination( assert ( 'Thu, 01 Jun 2017 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert '0:57:36' == data['data']['activities'][0]['duration'] assert 'creation_date' in data['data']['activities'][1] assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) assert '0:17:04' == data['data']['activities'][1]['duration'] response = client.get( @@ -212,7 +212,7 @@ def test_get_activities_pagination_error( assert ( 'Error. Please try again or contact the administrator.' in data['message'] - ) # noqa + ) def test_get_activities_date_filter( @@ -240,13 +240,13 @@ def test_get_activities_date_filter( assert ( 'Fri, 23 Feb 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert '0:10:00' == data['data']['activities'][0]['duration'] assert 'creation_date' in data['data']['activities'][1] assert ( 'Fri, 23 Feb 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) assert '0:16:40' == data['data']['activities'][1]['duration'] @@ -298,11 +298,11 @@ def test_get_activities_date_filter_from( assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) def test_get_activities_date_filter_to( @@ -329,11 +329,11 @@ def test_get_activities_date_filter_to( assert ( 'Thu, 01 Jun 2017 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) def test_get_activities_date_filter_paginate( @@ -360,11 +360,11 @@ def test_get_activities_date_filter_paginate( assert ( 'Thu, 01 Jun 2017 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) def test_get_activities_order( @@ -391,11 +391,11 @@ def test_get_activities_order( assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Fri, 23 Feb 2018 00:00:00 GMT' == data['data']['activities'][4]['activity_date'] - ) # noqa + ) def test_get_activities_date_filter_paginate_order( @@ -422,11 +422,11 @@ def test_get_activities_date_filter_paginate_order( assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) def test_get_activities_distance_filter( @@ -453,11 +453,11 @@ def test_get_activities_distance_filter( assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) def test_get_activities_duration_filter( @@ -484,7 +484,7 @@ def test_get_activities_duration_filter( assert ( 'Thu, 01 Jun 2017 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) def test_get_activities_ave_speed_filter( @@ -511,7 +511,7 @@ def test_get_activities_ave_speed_filter( assert ( 'Fri, 23 Feb 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) def test_get_activities_max_speed_filter( @@ -545,7 +545,7 @@ def test_get_activities_max_speed_filter( assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) def test_get_activities_sport_filter( @@ -577,7 +577,7 @@ def test_get_activities_sport_filter( assert ( 'Sun, 01 Apr 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) def test_get_an_activity( @@ -607,8 +607,8 @@ def test_get_an_activity( assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa - assert 1 == data['data']['activities'][0]['user_id'] + ) + assert 'test' == data['data']['activities'][0]['user'] assert 1 == data['data']['activities'][0]['sport_id'] assert 10.0 == data['data']['activities'][0]['distance'] assert '0:17:04' == data['data']['activities'][0]['duration'] @@ -662,11 +662,11 @@ def test_get_activities_per_page( assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Mon, 20 Mar 2017 00:00:00 GMT' == data['data']['activities'][6]['activity_date'] - ) # noqa + ) response = client.get( '/api/activities?per_page=3', @@ -683,11 +683,11 @@ def test_get_activities_per_page( assert ( 'Wed, 09 May 2018 00:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Fri, 23 Feb 2018 00:00:00 GMT' == data['data']['activities'][2]['activity_date'] - ) # noqa + ) def test_get_an_activity_invalid_id(app, user_1): diff --git a/fittrackee_api/fittrackee_api/tests/test_activities_api_1_post.py b/fittrackee_api/fittrackee_api/tests/test_activities_api_1_post.py index 2a456609..c5765c9f 100644 --- a/fittrackee_api/fittrackee_api/tests/test_activities_api_1_post.py +++ b/fittrackee_api/fittrackee_api/tests/test_activities_api_1_post.py @@ -11,8 +11,8 @@ def assert_activity_data_with_gpx(data): assert ( 'Tue, 13 Mar 2018 12:44:45 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa - assert 1 == data['data']['activities'][0]['user_id'] + ) + assert 'test' == data['data']['activities'][0]['user'] assert 1 == data['data']['activities'][0]['sport_id'] assert '0:04:10' == data['data']['activities'][0]['duration'] assert data['data']['activities'][0]['ascent'] == 0.4 @@ -74,8 +74,8 @@ def assert_activity_data_with_gpx_segments(data): assert ( 'Tue, 13 Mar 2018 12:44:45 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa - assert 1 == data['data']['activities'][0]['user_id'] + ) + assert 'test' == data['data']['activities'][0]['user'] assert 1 == data['data']['activities'][0]['sport_id'] assert '0:04:10' == data['data']['activities'][0]['duration'] assert data['data']['activities'][0]['ascent'] == 0.4 @@ -148,14 +148,14 @@ def assert_activity_data_wo_gpx(data): assert ( data['data']['activities'][0]['activity_date'] == 'Tue, 15 May 2018 14:05:00 GMT' - ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + ) + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] == '1:00:00' assert ( data['data']['activities'][0]['title'] == 'Cycling - 2018-05-15 14:05:00' - ) # noqa + ) assert data['data']['activities'][0]['ascent'] is None assert data['data']['activities'][0]['ave_speed'] == 10.0 assert data['data']['activities'][0]['descent'] is None @@ -562,7 +562,7 @@ def test_add_an_activity_with_gpx_without_name( assert ( 'Cycling - 2018-03-13 12:44:45' == data['data']['activities'][0]['title'] - ) # noqa + ) assert_activity_data_with_gpx(data) @@ -596,7 +596,7 @@ def test_add_an_activity_with_gpx_without_name_timezone( assert ( 'Cycling - 2018-03-13 13:44:45' == data['data']['activities'][0]['title'] - ) # noqa + ) assert_activity_data_with_gpx(data) @@ -948,11 +948,11 @@ def test_get_an_activity_wo_gpx_with_timezone(app, user_1, sport_1_cycling): assert ( data['data']['activities'][0]['activity_date'] == 'Tue, 15 May 2018 12:05:00 GMT' - ) # noqa + ) assert ( data['data']['activities'][0]['title'] == 'Cycling - 2018-05-15 14:05:00' - ) # noqa + ) def test_get_activities_date_filter_with_timezone_new_york( @@ -995,11 +995,11 @@ def test_get_activities_date_filter_with_timezone_new_york( assert ( 'Mon, 01 Jan 2018 05:00:00 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert ( 'Cycling - 2018-01-01 00:00:00' == data['data']['activities'][0]['title'] - ) # noqa + ) def test_get_activities_date_filter_with_timezone_paris( @@ -1080,16 +1080,16 @@ def test_get_activities_date_filter_with_timezone_paris( assert ( 'Wed, 31 Jan 2018 21:59:59 GMT' == data['data']['activities'][0]['activity_date'] - ) # noqa + ) assert 'Test' == data['data']['activities'][0]['title'] assert ( 'Sun, 31 Dec 2017 23:00:00 GMT' == data['data']['activities'][1]['activity_date'] - ) # noqa + ) assert ( 'Cycling - 2018-01-01 00:00:00' == data['data']['activities'][1]['title'] - ) # noqa + ) def test_add_an_activity_no_gpx_invalid_payload(app, user_1, sport_1_cycling): @@ -1177,8 +1177,8 @@ def test_add_activity_zero_value( assert ( data['data']['activities'][0]['activity_date'] == 'Mon, 14 May 2018 14:05:00 GMT' - ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + ) + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] is None assert data['data']['activities'][0]['title'] == 'Activity test' # noqa @@ -1259,7 +1259,7 @@ def test_get_an_activity_with_zip_folder(app, user_1, sport_1_cycling): def test_get_an_activity_with_zip_incorrect_file(app, user_1, sport_1_cycling): file_path = os.path.join( app.root_path, 'tests/files/gpx_test_incorrect.zip' - ) # noqa + ) # 'gpx_test_incorrect.zip' contains 2 gpx files, one is incorrect with open(file_path, 'rb') as zip_file: diff --git a/fittrackee_api/fittrackee_api/tests/test_activities_api_2_patch.py b/fittrackee_api/fittrackee_api/tests/test_activities_api_2_patch.py index 2e7ee987..428950bb 100644 --- a/fittrackee_api/fittrackee_api/tests/test_activities_api_2_patch.py +++ b/fittrackee_api/fittrackee_api/tests/test_activities_api_2_patch.py @@ -10,7 +10,7 @@ def assert_activity_data_with_gpx(data): 'Tue, 13 Mar 2018 12:44:45 GMT' == data['data']['activities'][0]['activity_date'] ) # noqa - assert 1 == data['data']['activities'][0]['user_id'] + assert 'test' == data['data']['activities'][0]['user'] assert '0:04:10' == data['data']['activities'][0]['duration'] assert data['data']['activities'][0]['ascent'] == 0.4 assert data['data']['activities'][0]['ave_speed'] == 4.61 @@ -303,7 +303,7 @@ def test_edit_an_activity_wo_gpx( data['data']['activities'][0]['activity_date'] == 'Mon, 14 May 2018 14:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] == '1:00:00' assert data['data']['activities'][0]['title'] == 'Activity test' # noqa @@ -372,7 +372,7 @@ def test_edit_an_activity_wo_gpx( data['data']['activities'][0]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 2 assert data['data']['activities'][0]['duration'] == '1:00:00' assert data['data']['activities'][0]['title'] == 'Activity test' @@ -433,7 +433,7 @@ def test_edit_an_activity_wo_gpx( data['data']['activities'][0]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 2 assert data['data']['activities'][0]['duration'] == '1:00:00' assert data['data']['activities'][0]['title'] == 'Activity test' @@ -569,7 +569,7 @@ def test_edit_an_activity_wo_gpx_timezone( data['data']['activities'][0]['activity_date'] == 'Mon, 14 May 2018 12:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] == '1:00:00' assert ( @@ -637,7 +637,7 @@ def test_edit_an_activity_wo_gpx_timezone( data['data']['activities'][0]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 2 assert data['data']['activities'][0]['duration'] == '1:00:00' assert data['data']['activities'][0]['title'] == 'Activity test' # noqa @@ -710,7 +710,7 @@ def test_edit_an_activity_wo_gpx_partial(app, user_1, sport_1_cycling): data['data']['activities'][0]['activity_date'] == 'Mon, 14 May 2018 14:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] == '1:00:00' assert ( @@ -771,7 +771,7 @@ def test_edit_an_activity_wo_gpx_partial(app, user_1, sport_1_cycling): data['data']['activities'][0]['activity_date'] == 'Mon, 14 May 2018 14:05:00 GMT' ) # noqa - assert data['data']['activities'][0]['user_id'] == 1 + assert data['data']['activities'][0]['user'] == 'test' assert data['data']['activities'][0]['sport_id'] == 1 assert data['data']['activities'][0]['duration'] == '1:00:00' assert ( diff --git a/fittrackee_api/fittrackee_api/tests/test_activities_model.py b/fittrackee_api/fittrackee_api/tests/test_activities_model.py index 8cb17662..ffd4a5bf 100644 --- a/fittrackee_api/fittrackee_api/tests/test_activities_model.py +++ b/fittrackee_api/fittrackee_api/tests/test_activities_model.py @@ -14,7 +14,7 @@ def test_add_activity(app, sport_1_cycling, user_1, activity_cycling_user_1): serialized_activity = activity_cycling_user_1.serialize() assert 1 == serialized_activity['id'] - assert 1 == serialized_activity['user_id'] + assert 'test' == serialized_activity['user'] assert 1 == serialized_activity['sport_id'] assert serialized_activity['title'] == 'Test' assert 'creation_date' in serialized_activity diff --git a/fittrackee_api/fittrackee_api/tests/test_records_api.py b/fittrackee_api/fittrackee_api/tests/test_records_api.py index 5c82bb70..b4744ac4 100644 --- a/fittrackee_api/fittrackee_api/tests/test_records_api.py +++ b/fittrackee_api/fittrackee_api/tests/test_records_api.py @@ -32,8 +32,8 @@ def test_get_records_for_authenticated_user( assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['records'][0]['activity_date'] - ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + ) + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 1 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -42,8 +42,8 @@ def test_get_records_for_authenticated_user( assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['records'][1]['activity_date'] - ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + ) + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -52,8 +52,8 @@ def test_get_records_for_authenticated_user( assert ( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['records'][2]['activity_date'] - ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + ) + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -63,7 +63,7 @@ def test_get_records_for_authenticated_user( 'Mon, 01 Jan 2018 00:00:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 1 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -181,7 +181,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 1 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -191,7 +191,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -201,7 +201,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -211,7 +211,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 1 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -253,7 +253,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -263,7 +263,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -273,7 +273,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -283,7 +283,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -324,7 +324,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -334,7 +334,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -344,7 +344,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -354,7 +354,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -388,7 +388,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -398,7 +398,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -408,7 +408,7 @@ def test_get_records_after_activities_post_and_patch( 'Wed, 16 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 3 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -418,7 +418,7 @@ def test_get_records_after_activities_post_and_patch( 'Tue, 15 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -449,7 +449,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 1 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -459,7 +459,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -469,7 +469,7 @@ def test_get_records_after_activities_post_and_patch( 'Wed, 16 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 3 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -479,7 +479,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 1 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -521,7 +521,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 1 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -531,7 +531,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -541,7 +541,7 @@ def test_get_records_after_activities_post_and_patch( 'Wed, 16 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 3 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -551,7 +551,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 1 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -595,7 +595,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 08:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 5 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -605,7 +605,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 08:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 5 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -615,7 +615,7 @@ def test_get_records_after_activities_post_and_patch( 'Wed, 16 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 3 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -625,7 +625,7 @@ def test_get_records_after_activities_post_and_patch( 'Mon, 14 May 2018 08:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 5 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -768,7 +768,7 @@ def test_get_records_after_sport_change( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 1 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -778,7 +778,7 @@ def test_get_records_after_sport_change( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 1 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -788,7 +788,7 @@ def test_get_records_after_sport_change( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -798,7 +798,7 @@ def test_get_records_after_sport_change( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 1 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -808,7 +808,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][4]['activity_date'] ) # noqa - assert 1 == data['data']['records'][4]['user_id'] + assert 'test' == data['data']['records'][4]['user'] assert 2 == data['data']['records'][4]['sport_id'] assert 2 == data['data']['records'][4]['activity_id'] assert 'AS' == data['data']['records'][4]['record_type'] @@ -818,7 +818,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][5]['activity_date'] ) # noqa - assert 1 == data['data']['records'][5]['user_id'] + assert 'test' == data['data']['records'][5]['user'] assert 2 == data['data']['records'][5]['sport_id'] assert 2 == data['data']['records'][5]['activity_id'] assert 'FD' == data['data']['records'][5]['record_type'] @@ -828,7 +828,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][6]['activity_date'] ) # noqa - assert 1 == data['data']['records'][6]['user_id'] + assert 'test' == data['data']['records'][6]['user'] assert 2 == data['data']['records'][6]['sport_id'] assert 2 == data['data']['records'][6]['activity_id'] assert 'LD' == data['data']['records'][6]['record_type'] @@ -838,7 +838,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][7]['activity_date'] ) # noqa - assert 1 == data['data']['records'][7]['user_id'] + assert 'test' == data['data']['records'][7]['user'] assert 2 == data['data']['records'][7]['sport_id'] assert 2 == data['data']['records'][7]['activity_id'] assert 'MS' == data['data']['records'][7]['record_type'] @@ -870,7 +870,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][0]['activity_date'] ) # noqa - assert 1 == data['data']['records'][0]['user_id'] + assert 'test' == data['data']['records'][0]['user'] assert 1 == data['data']['records'][0]['sport_id'] assert 2 == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] @@ -880,7 +880,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][1]['activity_date'] ) # noqa - assert 1 == data['data']['records'][1]['user_id'] + assert 'test' == data['data']['records'][1]['user'] assert 1 == data['data']['records'][1]['sport_id'] assert 2 == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] @@ -890,7 +890,7 @@ def test_get_records_after_sport_change( 'Mon, 14 May 2018 14:05:00 GMT' == data['data']['records'][2]['activity_date'] ) # noqa - assert 1 == data['data']['records'][2]['user_id'] + assert 'test' == data['data']['records'][2]['user'] assert 1 == data['data']['records'][2]['sport_id'] assert 1 == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] @@ -900,7 +900,7 @@ def test_get_records_after_sport_change( 'Wed, 16 May 2018 16:05:00 GMT' == data['data']['records'][3]['activity_date'] ) # noqa - assert 1 == data['data']['records'][3]['user_id'] + assert 'test' == data['data']['records'][3]['user'] assert 1 == data['data']['records'][3]['sport_id'] assert 2 == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] @@ -910,7 +910,7 @@ def test_get_records_after_sport_change( 'Fri, 18 May 2018 18:05:00 GMT' == data['data']['records'][4]['activity_date'] ) # noqa - assert 1 == data['data']['records'][4]['user_id'] + assert 'test' == data['data']['records'][4]['user'] assert 2 == data['data']['records'][4]['sport_id'] assert 4 == data['data']['records'][4]['activity_id'] assert 'AS' == data['data']['records'][4]['record_type'] @@ -920,7 +920,7 @@ def test_get_records_after_sport_change( 'Fri, 18 May 2018 18:05:00 GMT' == data['data']['records'][5]['activity_date'] ) # noqa - assert 1 == data['data']['records'][5]['user_id'] + assert 'test' == data['data']['records'][5]['user'] assert 2 == data['data']['records'][5]['sport_id'] assert 4 == data['data']['records'][5]['activity_id'] assert 'FD' == data['data']['records'][5]['record_type'] @@ -930,7 +930,7 @@ def test_get_records_after_sport_change( 'Fri, 18 May 2018 18:05:00 GMT' == data['data']['records'][6]['activity_date'] ) # noqa - assert 1 == data['data']['records'][6]['user_id'] + assert 'test' == data['data']['records'][6]['user'] assert 2 == data['data']['records'][6]['sport_id'] assert 4 == data['data']['records'][6]['activity_id'] assert 'LD' == data['data']['records'][6]['record_type'] @@ -940,7 +940,7 @@ def test_get_records_after_sport_change( 'Fri, 18 May 2018 18:05:00 GMT' == data['data']['records'][7]['activity_date'] ) # noqa - assert 1 == data['data']['records'][7]['user_id'] + assert 'test' == data['data']['records'][7]['user'] assert 2 == data['data']['records'][7]['sport_id'] assert 4 == data['data']['records'][7]['activity_id'] assert 'MS' == data['data']['records'][7]['record_type'] diff --git a/fittrackee_api/fittrackee_api/tests/test_records_model.py b/fittrackee_api/fittrackee_api/tests/test_records_model.py index ccdd88a9..dfdd0ca4 100644 --- a/fittrackee_api/fittrackee_api/tests/test_records_model.py +++ b/fittrackee_api/fittrackee_api/tests/test_records_model.py @@ -9,7 +9,7 @@ def test_record_model(app, user_1, sport_1_cycling, activity_cycling_user_1): sport_id=activity_cycling_user_1.sport_id, record_type='LD', ).first() - assert 1 == record_ld.user_id + assert 'test' == record_ld.user.username assert 1 == record_ld.sport_id assert 1 == record_ld.activity_id assert 'LD' == record_ld.record_type @@ -18,7 +18,7 @@ def test_record_model(app, user_1, sport_1_cycling, activity_cycling_user_1): record_serialize = record_ld.serialize() assert 'id' in record_serialize - assert 'user_id' in record_serialize + assert 'user' in record_serialize assert 'sport_id' in record_serialize assert 'activity_id' in record_serialize assert 'record_type' in record_serialize @@ -35,7 +35,7 @@ def test_record_model_none_value( record_type='LD', ).first() record_ld.value = None - assert 1 == record_ld.user_id + assert 'test' == record_ld.user.username assert 1 == record_ld.sport_id assert 1 == record_ld.activity_id assert 'LD' == record_ld.record_type diff --git a/fittrackee_api/fittrackee_api/tests/test_stats_api.py b/fittrackee_api/fittrackee_api/tests/test_stats_api.py index d7b01207..12999064 100644 --- a/fittrackee_api/fittrackee_api/tests/test_stats_api.py +++ b/fittrackee_api/fittrackee_api/tests/test_stats_api.py @@ -9,7 +9,7 @@ def test_get_stats_by_time_no_activities(app, user_1): content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time', + f'/api/stats/{user_1.username}/by_time', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -58,7 +58,7 @@ def test_get_stats_by_time_all_activities_error( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from="2018-04-01&to=2018-04-30', + f'/api/stats/{user_1.username}/by_time?from="2018-04-01&to=2018-04-30', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -89,7 +89,7 @@ def test_get_stats_by_time_all_activities_invalid_period( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30&time=day', # noqa + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30&time=day', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -117,7 +117,7 @@ def test_get_stats_by_time_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time', + f'/api/stats/{user_1.username}/by_time', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -165,7 +165,7 @@ def test_get_stats_by_time_all_activities_april_2018( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30', + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -206,7 +206,8 @@ def test_get_stats_by_time_all_activities_april_2018_paris( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1_paris.id}/by_time?from=2018-04-01&to=2018-04-30', + f'/api/stats/{user_1_paris.username}/by_time?' + f'from=2018-04-01&to=2018-04-30', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -247,7 +248,7 @@ def test_get_stats_by_year_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?time=year', + f'/api/stats/{user_1.username}/by_time?time=year', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -295,7 +296,7 @@ def test_get_stats_by_year_all_activities_april_2018( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30&time=year', # noqa + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30&time=year', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -336,7 +337,7 @@ def test_get_stats_by_year_all_activities_april_2018_paris( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1_paris.id}/by_time?from=2018-04-01&to=2018-04-30&time=year', # noqa + f'/api/stats/{user_1_paris.username}/by_time?from=2018-04-01&to=2018-04-30&time=year', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -377,7 +378,7 @@ def test_get_stats_by_month_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?time=month', + f'/api/stats/{user_1.username}/by_time?time=month', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -453,7 +454,7 @@ def test_get_stats_by_month_all_activities_new_york( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1_full.id}/by_time?time=month', + f'/api/stats/{user_1_full.username}/by_time?time=month', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -529,7 +530,7 @@ def test_get_stats_by_month_all_activities_april_2018( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30&time=month', # noqa + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30&time=month', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -570,7 +571,7 @@ def test_get_stats_by_week_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1_full.id}/by_time?time=week', + f'/api/stats/{user_1_full.username}/by_time?time=week', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -646,7 +647,7 @@ def test_get_stats_by_week_all_activities_week_13( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30&time=week', # noqa + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30&time=week', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -687,7 +688,7 @@ def test_get_stats_by_weekm_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?time=weekm', + f'/api/stats/{user_1.username}/by_time?time=weekm', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -763,7 +764,7 @@ def test_get_stats_by_weekm_all_activities_week_13( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_time?from=2018-04-01&to=2018-04-30&time=weekm', # noqa + f'/api/stats/{user_1.username}/by_time?from=2018-04-01&to=2018-04-30&time=weekm', # noqa headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -804,7 +805,7 @@ def test_get_stats_by_sport_all_activities( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_sport', + f'/api/stats/{user_1.username}/by_sport', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -843,7 +844,7 @@ def test_get_stats_by_sport_all_activities_sport_1( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_sport?sport_id=1', + f'/api/stats/{user_1.username}/by_sport?sport_id=1', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -905,7 +906,7 @@ def test_get_stats_by_sport_all_activities_invalid_sport( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_sport?sport_id=999', + f'/api/stats/{user_1.username}/by_sport?sport_id=999', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -933,7 +934,7 @@ def test_get_stats_by_sport_all_activities_error( content_type='application/json', ) response = client.get( - f'/api/stats/{user_1.id}/by_sport?sport_id="999', + f'/api/stats/{user_1.username}/by_sport?sport_id="999', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] diff --git a/fittrackee_api/fittrackee_api/users/models.py b/fittrackee_api/fittrackee_api/users/models.py index 5b5b3b56..80a3a2dc 100644 --- a/fittrackee_api/fittrackee_api/users/models.py +++ b/fittrackee_api/fittrackee_api/users/models.py @@ -26,10 +26,10 @@ class User(db.Model): # does the week start Monday? weekm = db.Column(db.Boolean(50), default=False, nullable=False) activities = db.relationship( - 'Activity', lazy=True, backref=db.backref('users', lazy='joined') + 'Activity', lazy=True, backref=db.backref('user', lazy='joined') ) records = db.relationship( - 'Record', lazy=True, backref=db.backref('users', lazy='joined') + 'Record', lazy=True, backref=db.backref('user', lazy='joined') ) language = db.Column(db.String(50), nullable=True) diff --git a/fittrackee_client/src/actions/stats.js b/fittrackee_client/src/actions/stats.js index 834e65d4..fbecaa4d 100644 --- a/fittrackee_client/src/actions/stats.js +++ b/fittrackee_client/src/actions/stats.js @@ -1,8 +1,8 @@ import FitTrackeeGenericApi from '../fitTrackeeApi' import { setData, setError } from './index' -export const getStats = (userId, type, data) => dispatch => - FitTrackeeGenericApi.getData(`stats/${userId}/${type}`, data) +export const getStats = (userName, type, data) => dispatch => + FitTrackeeGenericApi.getData(`stats/${userName}/${type}`, data) .then(ret => { if (ret.status === 'success') { dispatch(setData('statistics', ret.data)) diff --git a/fittrackee_client/src/components/Common/Stats/index.jsx b/fittrackee_client/src/components/Common/Stats/index.jsx index 696ae407..d9f15888 100644 --- a/fittrackee_client/src/components/Common/Stats/index.jsx +++ b/fittrackee_client/src/components/Common/Stats/index.jsx @@ -13,7 +13,8 @@ class Statistics extends React.PureComponent { componentDidUpdate(prevProps) { if ( - (this.props.user.id && this.props.user.id !== prevProps.user.id) || + (this.props.user.username && + this.props.user.username !== prevProps.user.username) || this.props.statsParams !== prevProps.statsParams ) { this.updateData() @@ -21,9 +22,9 @@ class Statistics extends React.PureComponent { } updateData() { - if (this.props.user.id) { + if (this.props.user.username) { this.props.loadActivities( - this.props.user.id, + this.props.user.username, this.props.user.weekm, this.props.statsParams ) @@ -61,7 +62,7 @@ export default connect( user: state.user, }), dispatch => ({ - loadActivities: (userId, weekm, data) => { + loadActivities: (userName, weekm, data) => { const dateFormat = 'yyyy-MM-dd' // depends on user config (first day of week) const time = @@ -73,7 +74,7 @@ export default connect( to: format(data.end, dateFormat), time: time, } - dispatch(getStats(userId, data.type, params)) + dispatch(getStats(userName, data.type, params)) }, }) )(Statistics)