Skip to content
Snippets Groups Projects
Commit a10c96aa authored by jamie's avatar jamie
Browse files

feedMicroservice now producing list of ratings

Function working as intended in app.py, now returns list containing
all ratings from everyone you follow
parent 78b5ebcd
No related branches found
No related tags found
2 merge requests!23Merging current work on feedMicroservice,!22feedMicroservice now producing list of ratings
......@@ -20,45 +20,30 @@ def getFeed():
followings = (requests.post('http://localhost:3002/followings/getFollowings',
json={"userID": userID},
headers=headers)).json()
print(followings)
# followings = people that you are following
# followingsID = ids of people you are following
followingsID = []
for i in range (len(followings)):
followingsID.append(followings[i]['userID'])
print(followingsID)
ratingsFeed = [] # song info, rating, user who rated
ratingsFeed = [] # array containing an array for each person you follow which contains an array with song info, rating,
# user who rated for every song they have rated
for i in range (len(followingsID)):
id = int(followingsID[i]) # person your followings ID
# followerRatings = that users all ratings for all songs
followerRatings = (requests.get(f'http://localhost:5050/all_ratings?userID={id}')).json()
print(followerRatings)
user = (requests.post(f'http://localhost:3002/auth/getUser', json={"userID": id}, headers=headers)).json()
name = (user['username'])
user = (requests.post(f'http://localhost:3002/getUser', json={"userID": id}, headers=headers)).json()
print(user)
feedInfo = []
# followerRatings [{songID, rating}, {}, {}]
for j in range (len(followerRatings)):
song = (requests.get(f'http://localhost:5050/search_id/{followerRatings[j][0]}')).json()
# song.append(list(followerRatings[j][1]) + list(followingsID[i]))
feedInfo.append(song)
print(feedInfo)
ratingsFeed.append(followerRatings)
# for i in range (len(ratingsFeed)):
print(ratingsFeed)
# userID
song.append(followerRatings[j][1])
song.append(name)
ratingsFeed.append(song)
# get users' followings' ratings
# collate into one array sorted by recency
# return array
return 'done'
return ratingsFeed
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5051)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment