@@ -339,9 +339,11 @@ def get(self, handle, authed_user_id=None):
339339class HandleTrackList (HandleFullTrackList ):
340340 @auth_middleware ()
341341 @ns .doc (
342- id = """Get User by Handle""" ,
343- description = "Gets a single user by their handle" ,
344- params = {"handle" : "A User handle" },
342+ id = """Get Tracks by User Handle""" ,
343+ description = """Gets the tracks created by a user using the user's handle""" ,
344+ params = {
345+ "handle" : "A User handle" ,
346+ },
345347 responses = {200 : "Success" , 400 : "Bad request" , 500 : "Server error" },
346348 )
347349 @ns .expect (user_tracks_route_parser )
@@ -500,32 +502,6 @@ def get(self, handle):
500502 return super ()._get (handle )
501503
502504
503- favorites_response = make_response (
504- "favorites_response" , ns , fields .List (fields .Nested (activity_model ))
505- )
506- favorites_full_response = make_full_response (
507- "favorites_response_full" , full_ns , fields .List (fields .Nested (activity_model_full ))
508- )
509-
510-
511- @ns .route ("/<string:id>/favorites" )
512- class FavoritedTracks (Resource ):
513- @record_metrics
514- @ns .doc (
515- id = """Get Favorites""" ,
516- description = """Gets a user's favorite tracks""" ,
517- params = {"id" : "A User ID" },
518- responses = {200 : "Success" , 400 : "Bad request" , 500 : "Server error" },
519- )
520- @ns .marshal_with (favorites_response )
521- @cache (ttl_sec = 5 )
522- def get (self , id ):
523- decoded_id = decode_with_abort (id , ns )
524- favorites = get_saves ("tracks" , decoded_id )
525- favorites = list (map (extend_favorite , favorites ))
526- return success_response (favorites )
527-
528-
529505tags_route_parser = pagination_with_current_user_parser .copy ()
530506tags_route_parser .remove_argument ("offset" )
531507tags_response = make_response ("tags_response" , ns , fields .List (fields .String ))
@@ -552,6 +528,33 @@ def get(self, id):
552528 return success_response (tags )
553529
554530
531+ favorites_response = make_response (
532+ "favorites_response" , ns , fields .List (fields .Nested (activity_model ))
533+ )
534+ favorites_full_response = make_full_response (
535+ "favorites_response_full" , full_ns , fields .List (fields .Nested (activity_model_full ))
536+ )
537+
538+
539+ # different route from /<string:id>/favorites/tracks
540+ @ns .route ("/<string:id>/favorites" )
541+ class FavoritedTracks (Resource ):
542+ @record_metrics
543+ @ns .doc (
544+ id = """Get Favorites""" ,
545+ description = """Gets a user's favorite tracks""" ,
546+ params = {"id" : "A User ID" },
547+ responses = {200 : "Success" , 400 : "Bad request" , 500 : "Server error" },
548+ )
549+ @ns .marshal_with (favorites_response )
550+ @cache (ttl_sec = 5 )
551+ def get (self , id ):
552+ decoded_id = decode_with_abort (id , ns )
553+ favorites = get_saves ("tracks" , decoded_id )
554+ favorites = list (map (extend_favorite , favorites ))
555+ return success_response (favorites )
556+
557+
555558USER_FAVORITED_TRACKS_ROUTE = "/<string:id>/favorites/tracks"
556559
557560
@@ -591,20 +594,6 @@ def get(self, id):
591594 return self ._get (id )
592595
593596
594- @ns .route (USER_FAVORITED_TRACKS_ROUTE )
595- class UserFavoritedTracks (UserFavoritedTracksFull ):
596- @ns .doc (
597- id = """Get Favorites""" ,
598- description = """Gets a user's favorite tracks""" ,
599- params = {"id" : "A User ID" },
600- responses = {200 : "Success" , 400 : "Bad request" , 500 : "Server error" },
601- )
602- @ns .expect (pagination_with_current_user_parser )
603- @ns .marshal_with (favorites_response )
604- def get (self , id ):
605- return super ()._get (id )
606-
607-
608597history_response = make_full_response (
609598 "history_response" , ns , fields .List (fields .Nested (activity_model ))
610599)
@@ -622,7 +611,7 @@ class TrackHistoryFull(Resource):
622611 def _get (self , id ):
623612 args = pagination_with_current_user_parser .parse_args ()
624613 decoded_id = decode_with_abort (id , ns )
625- current_user_id = get_current_user_id (args ) # non optional?
614+ current_user_id = get_current_user_id (args )
626615 offset = format_offset (args )
627616 limit = format_limit (args )
628617 get_tracks_args = GetUserListeningHistoryArgs (
@@ -863,7 +852,7 @@ def get(self, id):
863852 "genre" , required = False , action = "append" , description = "List of Genres"
864853)
865854top_genre_users_response = make_response (
866- "top_genre_users_response+ " , ns , fields .List (fields .Nested (user_model ))
855+ "top_genre_users_response" , ns , fields .List (fields .Nested (user_model ))
867856)
868857top_genre_users_response_full = make_full_response (
869858 "top_genre_users_response_full" ,
@@ -1074,9 +1063,7 @@ def get(self, id):
10741063)
10751064
10761065
1077- @full_ns .route (
1078- "/content_node/<string:replica_type>" , doc = False
1079- ) # no non-full for this?
1066+ @full_ns .route ("/content_node/<string:replica_type>" , doc = False )
10801067class UsersByContentNode (Resource ):
10811068 @ns .doc (
10821069 id = """Get Users By Replica Type for Content Node""" ,
@@ -1264,10 +1251,10 @@ def get(self, id: str, supporter_user_id: str):
12641251 "get_supporting" , ns , fields .List (fields .Nested (supporting_response ))
12651252)
12661253
1267- USER_SUPPORTING_ROUTE = "/<string:id>/supporting"
1254+ USER_SUPPORTINGS_ROUTE = "/<string:id>/supporting"
12681255
12691256
1270- @ns .route (USER_SUPPORTING_ROUTE )
1257+ @ns .route (USER_SUPPORTINGS_ROUTE )
12711258class GetSupportings (Resource ):
12721259 @record_metrics
12731260 @ns .doc (
@@ -1291,8 +1278,12 @@ def get(self, id: str):
12911278 "full_get_supporting" , full_ns , fields .List (fields .Nested (supporting_response_full ))
12921279)
12931280
1281+ full_get_supporting_response = make_full_response (
1282+ "full_get_supporting" , full_ns , fields .List (fields .Nested (supporting_response_full ))
1283+ )
12941284
1295- @full_ns .route (USER_SUPPORTING_ROUTE )
1285+
1286+ @full_ns .route (USER_SUPPORTINGS_ROUTE )
12961287class FullGetSupportings (Resource ):
12971288 @record_metrics
12981289 @full_ns .doc (
@@ -1318,24 +1309,14 @@ def get(self, id: str):
13181309 "full_get_supporting" , full_ns , fields .Nested (supporting_response_full )
13191310)
13201311
1312+ GET_SUPPORTING_ROUTE = "/<string:id>/supporting/<string:supported_user_id>"
1313+
13211314
1322- @full_ns .route (
1323- "/<string:id>/supporting/<string:supported_user_id>"
1324- ) # non full not necessary here either?
1315+ @full_ns .route (GET_SUPPORTING_ROUTE )
13251316class FullGetSupporting (Resource ):
13261317 @record_metrics
1327- @full_ns .doc (
1328- id = """Get Supporting""" ,
1329- description = """Gets the support from the given user to the supported user""" ,
1330- params = {
1331- "id" : "A User ID" ,
1332- "supported_user_id" : "A User ID of a supported user" ,
1333- },
1334- )
1335- @full_ns .expect (current_user_parser )
1336- @full_ns .marshal_with (full_get_supporting_response )
13371318 @cache (ttl_sec = 5 )
1338- def get (self , id : str , supported_user_id : str ):
1319+ def _get (self , id : str , supported_user_id : str ):
13391320 args = current_user_parser .parse_args ()
13401321 decoded_id = decode_with_abort (id , full_ns )
13411322 current_user_id = get_current_user_id (args )
@@ -1349,6 +1330,35 @@ def get(self, id: str, supported_user_id: str):
13491330 abort_not_found (decoded_id , full_ns )
13501331 return success_response (support [0 ])
13511332
1333+ @full_ns .doc (
1334+ id = """Get Supporting""" ,
1335+ description = """Gets the support from the given user to the supported user""" ,
1336+ params = {
1337+ "id" : "A User ID" ,
1338+ "supported_user_id" : "A User ID of a supported user" ,
1339+ },
1340+ )
1341+ @full_ns .expect (current_user_parser )
1342+ @full_ns .marshal_with (full_get_supporting_response )
1343+ def get (self , id : str , supported_user_id : str ):
1344+ return self ._get (id , supported_user_id )
1345+
1346+
1347+ @ns .route (GET_SUPPORTING_ROUTE )
1348+ class GetSupporting (FullGetSupporting ):
1349+ @ns .doc (
1350+ id = """Get Supporting""" ,
1351+ description = """Gets the support from the given user to the supported user""" ,
1352+ params = {
1353+ "id" : "A User ID" ,
1354+ "supported_user_id" : "A User ID of a supported user" ,
1355+ },
1356+ )
1357+ @ns .expect (current_user_parser )
1358+ @ns .marshal_with (get_supporting_response )
1359+ def get (self , id : str , supported_user_id : str ):
1360+ return super ()._get (id , supported_user_id )
1361+
13521362
13531363verify_token_response = make_response (
13541364 "verify_token" , ns , fields .Nested (decoded_user_token )
0 commit comments