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

Add similar projects at the bottom of the project detail page. #5632

Merged
merged 19 commits into from
Jun 1, 2023

Conversation

Aadesh-Baral
Copy link
Contributor

@Aadesh-Baral Aadesh-Baral commented Mar 14, 2023

closes #5626
This PR adds similar projects at the bottom of the project detail page.
realted_projects

Implementation:

  • Similarity between the projects and given project will be calculated using cosine similarity and top 4 projects will be returned by default.
  • Similarity between projects is calculated using these fields. -> default_locale, difficulty, mapping_types, country, categories
  • All published projects except private ones are displayed on non logged in view while only projects in which user has permission to map are shown for a logged in user.
  • The function to create project matrix, which is the most significant part of calculating project similarity will be cached for a day.

How to test:

  • Install backend dependencies as new dependencies has been added in this PR.
  • Start frontend and backend locally.
  • Go to project detail page of any published projects
  • Check if Similar projects button is visible on the footer alongside question & comments, contributors ....
  • Click on similar projects button. You should be scrolled to Similar projects section.
  • On the similar projects section 4 other similar projects should be displayed.

@ramyaragupathy
Copy link
Member

@Aadesh-Baral - can you also please add context on how the metadata fields were chosen to determine similarity between projects?

@Aadesh-Baral Aadesh-Baral marked this pull request as ready for review March 28, 2023 10:24
@Aadesh-Baral
Copy link
Contributor Author

To find similar projects, we analyzed the correlation between different project metadata fields and iterated through them. For instance, we observed that organizations tend to create similar projects based on their country and category. However, considering the organization for the similarity score led to the display of projects from the same organization, which affected the diversity of our displayed projects. Hence, we excluded organization as a field. Furthermore, we found some fields that didn't significantly contribute to our results, so we discarded them to enhance performance.
Then the result was tested with some test users who found it to be satisfactory.

@Aadesh-Baral
Copy link
Contributor Author

Adding @HelNershingThapa to review frontend changes and @d-rita to review backend changes.

Copy link
Contributor

@HelNershingThapa HelNershingThapa left a comment

Choose a reason for hiding this comment

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

When you click the related project card, the page should scroll to the top so that users feel like they are viewing another project when they navigate to the related project. Use the useFetch hook to fetch linked projects as well, making the component look cleaner. Other than that, LGTM, I've pushed with the requested changes.

Copy link
Contributor

@d-rita d-rita left a comment

Choose a reason for hiding this comment

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

@Aadesh-Baral will the limit of the projects returned always be 4? We have a limit parameter that we don't actually give the user a chance to use in the endpoint

Copy link
Contributor

@d-rita d-rita left a comment

Choose a reason for hiding this comment

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

Tested this, and it works as expected. The tests are good too. Overall, LGTM

@Aadesh-Baral
Copy link
Contributor Author

Now the function to create project matrices is cached instead of the function that returns related projects. This change significantly improves our performance, as in cases where 'current_user' changes, the entire function would need to be re-run, causing a significant performance impact. By caching the 'create_project_matrix' function, we can optimize performance, as this function is a major component of calculating related projects and needs recalculation very rarely.

Copy link
Member

@ramyaragupathy ramyaragupathy left a comment

Choose a reason for hiding this comment

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

Tested the basic functionality with @d-rita. Need to dig some more for edge cases @Aadesh-Baral

@Aadesh-Baral Aadesh-Baral force-pushed the feature/5626-related_projects branch from 956ac34 to 8fa8975 Compare May 8, 2023 05:27
Copy link
Member

@ramyaragupathy ramyaragupathy left a comment

Choose a reason for hiding this comment

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

Looks good to me @Aadesh-Baral

@Aadesh-Baral Aadesh-Baral changed the title Add related projects at the bottom of the project detail page. Add similar projects at the bottom of the project detail page. May 31, 2023
Aadesh-Baral and others added 19 commits June 1, 2023 14:25
It is preferable to filter projects by completion when creating results rather than when creating project matrixes so that users can view related projects of completed projects and contribute to other projects that are similar to them.
Cache the function to generate project matrices instead of the function that returns related projects. This change significantly improves our performance, as in cases where 'current_user' changes, the entire function would need to be re-run, causing a significant performance impact. By caching the 'create_project_matrix' function, we can optimize performance, as this function is a major component of calculating related projects and needs recalculation very rarely.
When an error occurred while fetching related projects, add the message 'could not find related projects for this project.' This was done to ensure that when an error occurs in related projects, the entire project detail page is not impacted.
- Updated test_create_project_matrix_returns_project_matrix adding project_id on create_project_matrix to update cache
- Mock get_similar_project_ids on test_get_related_projects_returns_related_projects
- Remove test_only_non_completed_projects_are_returned as we no longer filter project by completion while fetching published projects see 178fdf1
---------------------------------------------------------------------
Since we are calculating project similarity rather than their relation, this change is done to align the wording with the logic that has been applied.
@Aadesh-Baral Aadesh-Baral force-pushed the feature/5626-related_projects branch from 8fa8975 to fe0029c Compare June 1, 2023 10:23
@sonarcloud
Copy link

sonarcloud bot commented Jun 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Aadesh-Baral Aadesh-Baral merged commit 9a260e8 into develop Jun 1, 2023
8 checks passed
@Aadesh-Baral Aadesh-Baral deleted the feature/5626-related_projects branch June 1, 2023 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Recommend related projects to user on project detail view
4 participants