-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommend Projects View and URL #458
Conversation
…ject user is viewing, create helper methods for view in utils, create url to call view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I really like the randomization idea and the fallback of using the most popular projects! I left a few comments on how we can make this more efficient by making less queries to the DB but overall the algo seems to work.
if len(projects) == 3: | ||
return projects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idt this check is needed. the length should only change after an append
for j in Project.objects.filter(category__name=category).order_by('?'): | ||
tags_j = list(j.tags.all()) | ||
# skip original project and any projects already added to projects | ||
if j == project or j in projects: | ||
continue | ||
# if the jth project's tags include the ith tag, add to projects | ||
if i in tags_j: | ||
projects.append(j) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to make this a little cleaner and prevent redundant checks, we can get all the projects that are PUBLIC
and that aren't the project that was passed into the function with a filter query at the top. Then all subsequent filters can be done on that. This would remove the need for the 361 check and also ensure we aren't looking at projects that are drafts. Also we can add a filter to 358 that also ensures that the projects have tags that include the ith
tag. Check this for more info. This would also remove the need for the 364 line.
Summary
Create ProjectRecommendAPIView and endpoint to recommend 3 projects based on:
Closes #417
Changes