zubhub icon indicating copy to clipboard operation
zubhub copied to clipboard

Improve more projects section

Open brrkrmn opened this issue 1 year ago • 1 comments

Summary

'More Projects' section used to show the projects of the same user instead of showing similar projects from any user. With this PR, this section sends a request to the backend with the current project's id and retrieves 3 recommended projects depending on the project's categories.

Closes #1013

The changes in backend is adapted from @anthonycruzmacedo 's code in #458

Changes

Frontend

  • api function is created to send a request to projects/${id}/recommend/
  • error cases handled in projectActions.js with getMoreProjects function
  • projectDetails.jsx uses getMoreProjects to render the recommended projects

Backend

  • '<uuid:pk>/recommend/' url is used to recommend projects
  • ProjectRecommendAPIView class returns 3 recommended projects
  • recommend_projects function handles the logic to determine the 3 projects by checking the projects with the same category/categories, and show the most liked projects if there's none.

Screenshots

Before

  • shows the same user Screenshot 2023-12-12 at 23 33 16
  • shows empty section when projects not found Screenshot 2023-12-12 at 23 42 01

After

  • shows other projects with the same categories from any user Screenshot 2023-12-12 at 23 40 15
  • shows most liked projects when no other project with the same category is found Screenshot 2023-12-12 at 23 42 59

Update

With the updated function, the projects are filtered based on their title, tags and categories. When doing title check, the project title is converted into an array of strings and each word is mapped. If any of the words are found in other titles, the project is appended. I will refer to these projects with 'similar title' in this PR.

First loop is done with the similar titled projects, looking for:

  • Similar title, 1 matching category and 1 matching tag
  • (if above filter's results are empty:) Similar title, 1 matching category or tag
  • (if above filter's results are empty:) Similar title

Second loop looks for projects with:

  • 1 matching category and 1 matching tag,
  • (if above filter's results are empty:) 1 matching category or 1 matching tag

Third loop looks for the most liked projects

brrkrmn avatar Dec 12 '23 20:12 brrkrmn

the code looks good. Still need to manually test the PR

NdibeRaymond avatar Feb 02 '24 17:02 NdibeRaymond

pre-commit checks failed ❌❌❌ make sure you have pre-commit set up locally (see the README.md for instructions). If you have set up pre-commit locally, you may need to undo this commit and run "pre-commit" locally to see what the errors are.

github-actions[bot] avatar Jun 02 '24 19:06 github-actions[bot]

All pre-commit checks passed ✅✅✅

github-actions[bot] avatar Jun 02 '24 20:06 github-actions[bot]