Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

anthonycruzmacedo
Copy link
Contributor

Summary

Create ProjectRecommendAPIView and endpoint to recommend 3 projects based on:

  • first: add those in same category containing first tag, then those in same category containing second tag, ...
  • second: add those in same category
  • third: add most popular projects by likes
  • stop in any of these steps once we have retrieved three projects

Closes #417

Changes

  • ProjectRecommendAPIView in /projects/views.py
  • recommend endpdoint in /projects/urls.py
  • helper functions recommend_projects and recommend_projects_by_likes in /projects/utils.py

Copy link
Contributor

@ajain1921 ajain1921 left a 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.

Comment on lines +370 to +371
if len(projects) == 3:
return projects
Copy link
Contributor

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

Comment on lines +358 to +365
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)
Copy link
Contributor

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.

@abetco abetco added the h4i Hack4Impact issue label May 3, 2022
@srish srish closed this Sep 7, 2023
@tuxology tuxology deleted the acm/recommend-projects branch September 28, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
h4i Hack4Impact issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Recommended Projects Endpoint
4 participants