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

Improve more projects section #1020

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Conversation

brrkrmn
Copy link
Collaborator

@brrkrmn brrkrmn commented Dec 12, 2023

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 brrkrmn marked this pull request as ready for review December 19, 2023 13:31
Copy link
Collaborator

@yokwejuste yokwejuste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

zubhub_backend/zubhub/projects/utils.py Outdated Show resolved Hide resolved
zubhub_backend/zubhub/projects/views.py Outdated Show resolved Hide resolved
zubhub_frontend/zubhub/src/store/actions/projectActions.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@yokwejuste yokwejuste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@NdibeRaymond
Copy link
Collaborator

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

@NdibeRaymond NdibeRaymond changed the base branch from master to staging May 21, 2024 18:13
@NdibeRaymond NdibeRaymond force-pushed the improve-more-projects branch 2 times, most recently from 88c9daf to 3c6a3ce Compare June 2, 2024 19:31
Copy link

github-actions bot commented Jun 2, 2024

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.

* create views and utils methods to recommend projects
* create api function to receive recommended projects in the frontend
* modify project filtering
* refactor recommend projects function

Issue: #1013
Signed-off-by: Ndibe Raymond Olisaemeka <rolisaemeka-ctr@wikimedia.org>
Copy link

github-actions bot commented Jun 2, 2024

All pre-commit checks passed ✅✅✅

@NdibeRaymond NdibeRaymond merged commit ac3f8cd into staging Jun 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'More Projects' section only shows the same user's projects
3 participants